~ubuntu-branches/ubuntu/oneiric/rhythmbox/oneiric

« back to all changes in this revision

Viewing changes to widgets/rb-header.c

  • Committer: Bazaar Package Importer
  • Author(s): Rico Tzschichholz
  • Date: 2011-07-29 16:41:38 UTC
  • mto: This revision was merged to the branch mainline in revision 191.
  • Revision ID: james.westby@ubuntu.com-20110729164138-wwicy8nqalm18ck7
Tags: upstream-2.90.1~20110802
ImportĀ upstreamĀ versionĀ 2.90.1~20110802

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include "rb-stock-icons.h"
39
39
#include "rb-header.h"
40
40
#include "rb-debug.h"
41
 
#include "rb-preferences.h"
42
41
#include "rb-shell-player.h"
43
 
#include "eel-gconf-extensions.h"
44
42
#include "rb-util.h"
45
43
#include "rhythmdb.h"
46
44
#include "rb-player.h"
71
69
                                    guint prop_id,
72
70
                                    GValue *value,
73
71
                                    GParamSpec *pspec);
74
 
static void rb_header_set_show_timeline (RBHeader *header,
75
 
                                         gboolean show);
76
72
static void rb_header_update_elapsed (RBHeader *header);
77
73
static void apply_slider_position (RBHeader *header);
78
74
static gboolean slider_press_callback (GtkWidget *widget, GdkEventButton *event, RBHeader *header);
96
92
 
97
93
        GtkWidget *timeline;
98
94
        GtkWidget *scaleline;
99
 
        gboolean scaleline_shown;
 
95
        gboolean show_remaining;
100
96
 
101
97
        GtkWidget *scale;
102
98
        GtkAdjustment *adjustment;
117
113
        PROP_DB,
118
114
        PROP_SHELL_PLAYER,
119
115
        PROP_SEEKABLE,
120
 
        PROP_SLIDER_DRAGGING
 
116
        PROP_SLIDER_DRAGGING,
 
117
        PROP_SHOW_REMAINING,
 
118
        PROP_SHOW_POSITION_SLIDER
121
119
};
122
120
 
123
121
#define TITLE_FORMAT  "<big><b>%s</b></big>"
190
188
                                                               "slider dragging",
191
189
                                                               FALSE,
192
190
                                                               G_PARAM_READABLE));
 
191
        /**
 
192
         * RBHeader:show-remaining:
 
193
         *
 
194
         * Whether to show remaining time (as opposed to elapsed time) in the numeric
 
195
         * time display.
 
196
         */
 
197
        g_object_class_install_property (object_class,
 
198
                                         PROP_SHOW_REMAINING,
 
199
                                         g_param_spec_boolean ("show-remaining",
 
200
                                                               "show remaining",
 
201
                                                               "whether to show remaining or elapsed time",
 
202
                                                               FALSE,
 
203
                                                               G_PARAM_READWRITE));
 
204
 
 
205
        /**
 
206
         * RBHeader:show-position-slider:
 
207
         *
 
208
         * Whether to show the playback position slider.
 
209
         */
 
210
        g_object_class_install_property (object_class,
 
211
                                         PROP_SHOW_POSITION_SLIDER,
 
212
                                         g_param_spec_boolean ("show-position-slider",
 
213
                                                               "show position slider",
 
214
                                                               "whether to show the playback position slider",
 
215
                                                               TRUE,
 
216
                                                               G_PARAM_READWRITE));
193
217
 
194
218
        g_type_class_add_private (klass, sizeof (RBHeaderPrivate));
195
219
}
243
267
        /* row for the position slider */
244
268
        header->priv->scaleline = gtk_hbox_new (FALSE, 3);
245
269
        gtk_box_pack_start (GTK_BOX (vbox), header->priv->scaleline, FALSE, FALSE, 0);
246
 
        header->priv->scaleline_shown = FALSE;
247
270
 
248
271
        header->priv->adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 10.0, 1.0, 10.0, 0.0));
249
272
        header->priv->scale = gtk_hscale_new (header->priv->adjustment);
341
364
        case PROP_SEEKABLE:
342
365
                header->priv->seekable = g_value_get_boolean (value);
343
366
                break;
 
367
        case PROP_SHOW_REMAINING:
 
368
                header->priv->show_remaining = g_value_get_boolean (value);
 
369
                rb_header_update_elapsed (header);
 
370
                break;
 
371
        case PROP_SHOW_POSITION_SLIDER:
 
372
                gtk_widget_set_visible (header->priv->scaleline, g_value_get_boolean (value));
 
373
                break;
344
374
        default:
345
375
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
346
376
                break;
368
398
        case PROP_SLIDER_DRAGGING:
369
399
                g_value_set_boolean (value, header->priv->slider_dragging);
370
400
                break;
 
401
        case PROP_SHOW_REMAINING:
 
402
                g_value_set_boolean (value, header->priv->show_remaining);
 
403
                break;
 
404
        case PROP_SHOW_POSITION_SLIDER:
 
405
                g_value_set_boolean (value, gtk_widget_get_visible (header->priv->scaleline));
 
406
                break;
371
407
        default:
372
408
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
373
409
                break;
538
574
                gtk_label_set_markup (GTK_LABEL (header->priv->song), label_text);
539
575
                g_free (label_text);
540
576
 
541
 
                rb_header_set_show_timeline (header, have_duration && header->priv->seekable);
 
577
                gtk_widget_set_sensitive (header->priv->scaleline, have_duration && header->priv->seekable);
542
578
                if (have_duration)
543
579
                        rb_header_sync_time (header);
544
580
 
551
587
                gtk_label_set_markup (GTK_LABEL (header->priv->song), label_text);
552
588
                g_free (label_text);
553
589
 
554
 
                rb_header_set_show_timeline (header, FALSE);
 
590
                gtk_widget_set_sensitive (header->priv->scaleline, FALSE);
555
591
 
556
592
                header->priv->slider_locked = TRUE;
557
593
                gtk_adjustment_set_value (header->priv->adjustment, 0.0);
563
599
}
564
600
 
565
601
/**
566
 
 * rb_header_set_show_position_slider:
567
 
 * @header: the #RBHeader
568
 
 * @show: whether the position slider should be shown
569
 
 *
570
 
 * Sets the visibility of the position slider.  This is not currently
571
 
 * used properly.
572
 
 */
573
 
void
574
 
rb_header_set_show_position_slider (RBHeader *header,
575
 
                                    gboolean show)
576
 
{
577
 
        if (header->priv->scaleline_shown == show)
578
 
                return;
579
 
 
580
 
        header->priv->scaleline_shown = show;
581
 
 
582
 
        if (show) {
583
 
                gtk_widget_show_all (GTK_WIDGET (header->priv->scaleline));
584
 
                rb_header_sync_time (header);
585
 
        } else {
586
 
                gtk_widget_hide (GTK_WIDGET (header->priv->scaleline));
587
 
        }
588
 
}
589
 
 
590
 
static void
591
 
rb_header_set_show_timeline (RBHeader *header,
592
 
                             gboolean show)
593
 
{
594
 
        gtk_widget_set_sensitive (header->priv->scaleline, show);
595
 
}
596
 
 
597
 
/**
598
602
 * rb_header_sync_time:
599
603
 * @header: the #RBHeader
600
604
 *
787
791
 
788
792
                elapsed_text = rb_make_elapsed_time_string (seconds,
789
793
                                                            header->priv->duration,
790
 
                                                            !eel_gconf_get_boolean (CONF_UI_TIME_DISPLAY));
 
794
                                                            header->priv->show_remaining);
791
795
                gtk_label_set_text (GTK_LABEL (header->priv->elapsed), elapsed_text);
792
796
                g_free (elapsed_text);
793
797
        } else {