~nataliabidart/software-center/winged-migration

« back to all changes in this revision

Viewing changes to softwarecenter/ui/gtk3/widgets/thumbnail.py

  • Committer: Natalia B. Bidart
  • Date: 2012-05-30 18:39:55 UTC
  • mto: This revision was merged to the branch mainline in revision 3030.
  • Revision ID: natalia.bidart@canonical.com-20120530183955-zbnjczayktmmg5tv
- Initial test cleanup:
  - Renamed test/ dir to tests/.
  - Isolated test code into tests/ directory, including moving all the
    get_test_window_foo from the gtk3 production modules to
    tests/gtk3/windows.py module.
  - Removed all the calls to Gtk.main() in gtk3 tests since that blocks the
    execution of the suite.
  - Pep8 and pyflakes fixes in the files already modified in this branch.
  - Minor bug fix in the softwarecenter/log.py module when trying to create a
    log dir with proper perms.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from gi.repository import Gtk, Gdk, Atk, Gio, GObject, GdkPixbuf
22
22
 
23
23
import logging
24
 
import os
25
24
 
26
 
from softwarecenter.db.pkginfo import get_pkg_info
27
25
from softwarecenter.utils import SimpleFileDownloader
28
26
 
29
27
from imagedialog import SimpleShowImageDialog
472
470
        thumb.set_state_flags(Gtk.StateFlags.SELECTED, False)
473
471
        self._prev = thumb
474
472
        self.emit("thumb-selected", thumb.id_)
475
 
 
476
 
 
477
 
def get_test_screenshot_thumbnail_window():
478
 
    icons = Gtk.IconTheme.get_default()
479
 
    icons.append_search_path("/usr/share/app-install/icons/")
480
 
 
481
 
    import softwarecenter.distro
482
 
    distro = softwarecenter.distro.get_distro()
483
 
 
484
 
    win = Gtk.Window()
485
 
    win.set_border_width(10)
486
 
 
487
 
    from gi.repository import Gdk
488
 
    from softwarecenter.ui.gtk3.utils import init_sc_css_provider
489
 
    from softwarecenter.ui.gtk3.widgets.containers import FramedBox
490
 
    init_sc_css_provider(win, Gtk.Settings.get_default(),
491
 
                         Gdk.Screen.get_default(), "data")
492
 
 
493
 
    t = ScreenshotGallery(distro, icons)
494
 
    t.connect('draw', t.draw)
495
 
    frame = FramedBox()
496
 
    frame.add(t)
497
 
    win.set_data("screenshot_thumbnail_widget", t)
498
 
 
499
 
    vb = Gtk.VBox(spacing=6)
500
 
    win.add(vb)
501
 
 
502
 
    b = Gtk.Button('A button for focus testing')
503
 
    vb.pack_start(b, True, True, 0)
504
 
    win.set_data("screenshot_button_widget", b)
505
 
    vb.pack_start(frame, True, True, 0)
506
 
 
507
 
    win.show_all()
508
 
    win.connect('destroy', Gtk.main_quit)
509
 
 
510
 
    return win
511
 
 
512
 
if __name__ == '__main__':
513
 
 
514
 
    app_n = 0
515
 
 
516
 
    def testing_cycle_apps(_, thumb, apps, db):
517
 
        global app_n
518
 
        d = apps[app_n].get_details(db)
519
 
 
520
 
        if app_n + 1 < len(apps):
521
 
            app_n += 1
522
 
        else:
523
 
            app_n = 0
524
 
 
525
 
        thumb.fetch_screenshots(d)
526
 
        return True
527
 
 
528
 
    logging.basicConfig(level=logging.DEBUG)
529
 
 
530
 
    cache = get_pkg_info()
531
 
    cache.open()
532
 
 
533
 
    from softwarecenter.db.database import StoreDatabase
534
 
    xapian_base_path = "/var/cache/software-center"
535
 
    pathname = os.path.join(xapian_base_path, "xapian")
536
 
    db = StoreDatabase(pathname, cache)
537
 
    db.open()
538
 
 
539
 
    w = get_test_screenshot_thumbnail_window()
540
 
    t = w.get_data("screenshot_thumbnail_widget")
541
 
    b = w.get_data("screenshot_button_widget")
542
 
 
543
 
    from softwarecenter.db.application import Application
544
 
    apps = [Application("Movie Player", "totem"),
545
 
            Application("Comix", "comix"),
546
 
            Application("Gimp", "gimp"),
547
 
            Application("ACE", "uace")]
548
 
 
549
 
    b.connect("clicked", testing_cycle_apps, t, apps, db)
550
 
 
551
 
    Gtk.main()