~ubuntu-branches/ubuntu/utopic/indicator-transfer/utopic

« back to all changes in this revision

Viewing changes to src/view-gmenu.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Charles Kerr
  • Date: 2014-10-07 19:48:01 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20141007194801-leihxswcevvug72c
Tags: 0.1+14.10.20141007-0ubuntu1
[ Charles Kerr ]
Change the indicator's label to "Files" and only show the indicator
if there are unfinished transfers. (LP: #1377275)

Show diffs side-by-side

added added

removed removed

Lines of Context:
238
238
                          g_variant_new_string("accessible-desc"));
239
239
    g_variant_builder_add(&b, "{sv}", "label", g_variant_new_string("label"));
240
240
    g_variant_builder_add(&b, "{sv}", "title", g_variant_new_string("title"));
241
 
    g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean(true));
 
241
    g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean(false));
242
242
    return g_variant_builder_end(&b);
243
243
  }
244
244
 
419
419
    return ret;
420
420
  }
421
421
 
 
422
  /* Show the header if there are any transfers that have begun and are
 
423
     currently incomplete because they're either ongoing or paused. */
 
424
  bool header_should_be_visible() const
 
425
  {
 
426
    for (const auto& transfer : m_model->get_all())
 
427
      if (transfer->state != Transfer::FINISHED)
 
428
        return true;
 
429
 
 
430
    return false;
 
431
  }
 
432
 
422
433
  GVariant* create_header_state()
423
434
  {
424
435
    auto reffed_icon_v = get_header_icon();
425
 
    auto title_v = g_variant_new_string(_("Transfers"));
 
436
    auto title_v = g_variant_new_string(_("Files"));
 
437
    const bool visible = header_should_be_visible();
426
438
 
427
439
    GVariantBuilder b;
428
440
    g_variant_builder_init(&b, G_VARIANT_TYPE_VARDICT);
429
441
    g_variant_builder_add(&b, "{sv}", "title", title_v);
430
442
    g_variant_builder_add(&b, "{sv}", "icon", reffed_icon_v);
431
443
    g_variant_builder_add(&b, "{sv}", "accessible-desc", title_v);
432
 
    g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean(true));
 
444
    g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean(visible));
433
445
    auto ret = g_variant_builder_end (&b);
434
446
 
435
447
    g_variant_unref(reffed_icon_v);