~ttosttos/noise/fix-1004294

« back to all changes in this revision

Viewing changes to src/Widgets/SpaceWidget.vala

  • Committer: Victor Eduardo
  • Date: 2012-05-23 04:03:02 UTC
  • mfrom: (771.1.1 noise)
  • Revision ID: victoreduardm@gmail.com-20120523040302-zak3zanmxej1fwcr
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
234
234
        left_box.pack_end (status_label, false, false, 5);
235
235
 
236
236
        /** SYNC BUTTON **/
237
 
        sync_button = new Button.with_label ("Sync");
 
237
        sync_button = new Button.with_label (_("Sync"));
238
238
        sync_button.set_size_request (80, -1);
239
239
 
240
240
        sync_button.clicked.connect ( ()=> {
264
264
        set_size (size);
265
265
 
266
266
        /** Adding free-space element **/
267
 
        add_item_at_pos ("Free", size, ItemColor.GREY, ItemPosition.END);
 
267
        add_item_at_pos (_("Free"), size, ItemColor.GREY, ItemPosition.END);
268
268
    }
269
269
 
270
270
    public void set_sync_button_sensitive (bool val) {
377
377
        // Setting bottom label text
378
378
        double used = total_size - free_space_size;
379
379
        double p = used / total_size * 100.0;
380
 
        status_label.set_text("Using %.2f of %.2f GB (%.2f%)".printf(used/1000.0, total_size/1000.0, p));
 
380
        status_label.set_text(_("Using %s of %s (%.2f%)").printf(GLib.format_size ((uint64)used), GLib.format_size ((uint64)total_size), p));
381
381
    }
382
382
 
383
383
    private void show_full_bar_item (bool show_item, ItemColor? color) {
527
527
    private Gtk.Label title_label;
528
528
    private Gtk.Label size_label;
529
529
 
530
 
    /** Base Unit: Megabytes (MB) **/
531
 
    const double MULT = 1000;
532
 
    const double MB = 1;
533
 
    const double GB = MULT * MB;
534
 
    const double TB = MULT * GB;
535
 
 
536
530
    public SpaceWidgetItem (int id, string name, double size, SpaceWidget.ItemColor color) {
537
531
        this.name = name;
538
532
        this.size = size;
570
564
 
571
565
    public void set_size (double s) {
572
566
        size = s;
573
 
        var size_text = new StringBuilder();
574
 
 
575
 
        if (size <= GB) {
576
 
            size_text.append ("%.2f".printf(size/MB));
577
 
            size_text.append (" MB");
578
 
        } else if (size <= TB) {
579
 
            size_text.append ("%.2f".printf(size/GB));
580
 
            size_text.append (" GB");
581
 
        } else {
582
 
            size_text.append ("%.2f".printf(size/TB));
583
 
            size_text.append (" TB");
584
 
        }
585
 
 
 
567
        
586
568
        if (size_label == null)
587
 
            size_label = new Label (size_text.str);
 
569
            size_label = new Label (GLib.format_size ((uint64)size));
588
570
        else
589
 
            size_label.set_text (size_text.str);
 
571
            size_label.set_text (GLib.format_size ((uint64)size));
590
572
    }
591
573
 
592
574
    public void show () {