~ubuntu-branches/ubuntu/hardy/gxine/hardy

« back to all changes in this revision

Viewing changes to src/info_widgets.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-03-21 11:24:59 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20080321112459-igb0jy01nytpdrzt
Tags: 0.5.901-1ubuntu1
* merge debian changes for hardy PPA. Remaining changes:
  - debian/control: added Xb-Npp-xxx tags accordingly to "firefox distro
    add-on suport" spec,
    (https://blueprints.launchpad.net/ubuntu/+spec/firefox-distro-addon-support)
* Feature Freeze exception granted in LP: #204563
* New upstream release fixes playing DVDs. LP: #128864
* mime.default: add "x-content/video-dvd;x-content/video-vcd;x-content/video-svcd;"
  to get it listed as a player for dvd and video cds in nautilus. Thanks to
  Sebastien Bacher for the hint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2002-2005 the xine-project
 
2
 * Copyright (C) 2002-2007 the xine-project
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or
5
5
 * modify it under the terms of the GNU General Public License as
16
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
17
17
 * USA
18
18
 *
19
 
 * $Id: info_widgets.c,v 1.19 2006/03/27 22:11:24 dsalt Exp $
20
 
 *
21
19
 * nice black information display areas
22
20
 */
23
21
 
35
33
 
36
34
#include "i18n.h"
37
35
#include "defs.h"
 
36
#include "gtkvideo.h"
38
37
#include "info_widgets.h"
 
38
#include "ui.h"
39
39
#include "utils.h"
40
40
#include "playlist.h"
41
41
#include "player.h"
54
54
struct gxineinfo_private_s
55
55
{
56
56
  gxineinfo_cb postinit, update;
57
 
  GtkWidget *line[MAX_LINES];
 
57
  GtkLabel *line[MAX_LINES];
58
58
  int data;
 
59
  struct {
 
60
    int time, length, tcount, tno, ccount, cno;
 
61
    gboolean remaining, seekable;
 
62
  } prev;
 
63
  gboolean force;
59
64
};
60
65
typedef struct gxineinfo_private_s gxineinfo_private_t;
61
66
 
184
189
  for (i = 0; i < height; ++i)
185
190
  {
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);
191
196
    if (!i && width)
192
197
      gtk_label_set_width_chars (GTK_LABEL (line), width);
231
236
  {
232
237
    gxineinfo_private_t *priv = GET_PRIVATE (objs->data);
233
238
    if (priv->line[lineno])
234
 
      gtk_label_set_text (GTK_LABEL (priv->line[lineno]), text);
 
239
      gtk_label_set_text (priv->line[lineno], text);
235
240
  }
236
241
  free (text);
237
242
}
379
384
    gchar full[132];
380
385
  } time;
381
386
 
382
 
  pthread_mutex_lock (&widgets_update_lock);
 
387
  if (pthread_mutex_trylock (&widgets_update_lock))
 
388
    return TRUE;
383
389
  gdk_threads_enter ();
384
390
 
385
391
  time.length[0] = time.current[0] = 0;
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);
393
400
 
394
401
  if (xine_get_status (stream) == XINE_STATUS_PLAY && !playlist_showing_logo ())
395
402
  {
396
 
 
397
403
    if (!xine_get_pos_length (stream, &pos_stream, &pos_time, &length_time))
398
404
      pos_stream = pos_time = length_time = 0;
399
405
 
401
407
      pos_time = length_time - pos_time;
402
408
 
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 */
 
414
 
 
415
    priv->prev.time = pos_time;
 
416
    priv->prev.length = length_time;
 
417
    priv->prev.remaining = state;
 
418
    priv->prev.seekable = seekable;
 
419
 
404
420
    int_to_timestring (pos_time, time.current, sizeof (time.current));
405
421
 
406
422
    length_time = round_second (length_time);
408
424
      int_to_timestring (length_time, time.length, sizeof (time.length));
409
425
    else
410
426
      snprintf (time.length, sizeof (time.length), "%s",
411
 
                xine_get_stream_info (stream, XINE_STREAM_INFO_SEEKABLE)
412
 
                  ? _("??:??:??") : _("live"));
 
427
                seekable ? _("??:??:??") : _("live"));
413
428
  }
414
429
  else
 
430
  {
 
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, "•");
 
435
  }
 
436
 
416
437
  if (priv->line[1])
417
438
  {
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);
420
441
  }
421
442
  else if (time.current[0])
422
443
  {
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);
426
447
  }
427
448
  else
428
 
    gtk_label_set_text (GTK_LABEL (priv->line[0]), "");
 
449
    gtk_label_set_text (priv->line[0], "");
429
450
 
 
451
finish:
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),
436
 
             count);
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),
441
 
             count);
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;
 
458
 
 
459
  if (priv->force || tcount != priv->prev.tcount || tno != priv->prev.tno
 
460
                  || ccount != priv->prev.ccount || cno != priv->prev.cno)
 
461
  {
 
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);
 
471
  }
443
472
#endif
444
473
 
 
474
  priv->force = FALSE;
445
475
  gdk_threads_leave ();
446
476
  pthread_mutex_unlock (&widgets_update_lock);
447
 
  return TRUE;
 
477
  return FALSE;
448
478
}
449
479
 
450
480
static gboolean
452
482
{
453
483
  if (event->button == 1)
454
484
  {
455
 
    GET_PRIVATE (data)->data ^= 1;
456
 
    update_time_widget_cb (data);
 
485
    gxineinfo_private_t *priv = GET_PRIVATE (data);
 
486
    int flag = (priv->data ^= 1);
 
487
    priv->force = TRUE;
 
488
 
 
489
    GList **listp = g_object_get_data ((GObject *) data, "gxine-chain");
 
490
    if (listp)
 
491
    {
 
492
      GList *item = *listp;
 
493
      while (item)
 
494
      {
 
495
        priv = GET_PRIVATE (item->data);
 
496
        priv->data = flag;
 
497
        priv->force = TRUE;
 
498
        item = item->next;
 
499
      }
 
500
      gxineinfo_update (*listp);
 
501
    }
 
502
    else
 
503
      update_time_widget_cb (data);
457
504
  }
458
505
  return TRUE;
459
506
}
462
509
postinit_time_widget (gpointer widget)
463
510
{
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);
467
515
 
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);
473
521
 
474
 
  g_timeout_add (500, update_time_widget_cb, widget);
475
522
  return FALSE;
476
523
}
477
524
 
478
525
GtkWidget *
479
 
create_time_widget (gboolean small)
 
526
create_time_widget (gboolean small, const GList *const *const listp)
480
527
{
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 */);
 
532
  if (listp)
 
533
    g_object_set_data ((GObject *) w, "gxine-chain", (gpointer) listp);
 
534
  return w;
484
535
}