Example #1
0
 def _icons(self):
     """
     Get Icons Theme Object.
     """
     if ImageBox._ICONS is not None:
         return ImageBox._ICONS
     with ImageBox._ICONS_MUTEX:
         if ImageBox._ICONS is not None:
             return ImageBox._ICONS
         _icons = get_sc_icon_theme(DATA_DIR)
         AppListStore._ICONS = _icons
         return _icons
Example #2
0
 def _icons(self):
     """
     Get Icons Theme Object.
     """
     if ImageBox._ICONS is not None:
         return ImageBox._ICONS
     with ImageBox._ICONS_MUTEX:
         if ImageBox._ICONS is not None:
             return ImageBox._ICONS
         _icons = get_sc_icon_theme(DATA_DIR)
         AppListStore._ICONS = _icons
         return _icons
Example #3
0
    def __init__(self):
        self._current_state_lock = False
        self._current_state = RigoViewStates.STATIC_VIEW_STATE
        self._state_transitions = {
            RigoViewStates.BROWSER_VIEW_STATE: (
                self._enter_browser_state,
                self._exit_browser_state),
            RigoViewStates.STATIC_VIEW_STATE: (
                self._enter_static_state,
                self._exit_static_state),
            RigoViewStates.APPLICATION_VIEW_STATE: (
                self._enter_application_state,
                self._exit_application_state),
            RigoViewStates.WORK_VIEW_STATE: (
                self._enter_work_state,
                self._exit_work_state),
            RigoViewStates.CONFUPDATES_VIEW_STATE: (
                self._enter_confupdates_state,
                self._exit_confupdates_state),
            RigoViewStates.NOTICEBOARD_VIEW_STATE: (
                self._enter_noticeboard_state,
                self._exit_noticeboard_state),
            RigoViewStates.PREFERENCES_VIEW_STATE: (
                self._enter_preferences_state,
                self._exit_preferences_state),
            RigoViewStates.REPOSITORY_VIEW_STATE: (
                self._enter_repository_state,
                self._exit_repository_state),
            RigoViewStates.GROUPS_VIEW_STATE: (
                self._enter_groups_state,
                self._exit_groups_state)
        }
        self._state_metadata = {
            RigoViewStates.BROWSER_VIEW_STATE: {
                "title": _("Search"),
                },
            RigoViewStates.STATIC_VIEW_STATE: {
                "title": _("Rigo Application Browser"),
                },
            RigoViewStates.APPLICATION_VIEW_STATE: {
                "title": _("Application"),
                },
            RigoViewStates.WORK_VIEW_STATE: {
                "title": _("Working Hard"),
                },
            RigoViewStates.CONFUPDATES_VIEW_STATE: {
                "title": _("Wake Up"),
                },
            RigoViewStates.NOTICEBOARD_VIEW_STATE: {
                "title": _("Important Stuff"),
                },
            RigoViewStates.PREFERENCES_VIEW_STATE: {
                "title": _("Breaking Stuff"),
                },
            RigoViewStates.REPOSITORY_VIEW_STATE: {
                "title": _("Repository Stuff"),
                },
            RigoViewStates.GROUPS_VIEW_STATE: {
                "title": _("Application Groups"),
                },
        }
        self._state_mutex = Lock()

        icons = get_sc_icon_theme(DATA_DIR)

        self._activity_rwsem = ReadersWritersSemaphore()

        # This relies on the fact that the installed packages repository
        # is lazily loaded (thus, schema update code is).
        self._entropy = Client()
        self._entropy_ws = EntropyWebService(self._entropy)

        preload_task = ParallelTask(self._entropy_ws.preload)
        preload_task.name = "PreloadEntropyWebService"
        preload_task.daemon = True
        preload_task.start()

        self._service = RigoServiceController(
            self, self._activity_rwsem,
            self._entropy, self._entropy_ws)

        app_handler = Rigo.RigoHandler(self, self._service)

        self._builder = Gtk.Builder()
        self._builder.add_from_file(os.path.join(DATA_DIR, "ui/gtk3/rigo.ui"))
        self._builder.connect_signals(app_handler)
        self._window = self._builder.get_object("rigoWindow")
        self._window.set_name("rigo-view")
        self._apps_view = self._builder.get_object("appsViewVbox")
        self._scrolled_view = self._builder.get_object("appsViewScrolledWindow")
        self._app_view = self._builder.get_object("appViewScrollWin")
        self._app_view.set_name("rigo-view")
        self._app_view_port = self._builder.get_object("appViewVport")
        self._app_view_port.set_name("rigo-view")
        self._not_found_box = self._builder.get_object("appsViewNotFoundVbox")

        self._config_scrolled_view = self._builder.get_object(
            "configViewScrolledWindow")
        self._config_view = self._builder.get_object("configViewVbox")
        self._config_view.set_name("rigo-view")

        self._repo_scrolled_view = self._builder.get_object(
            "repoViewScrolledWindow")
        self._repo_view = self._builder.get_object("repoViewVbox")
        self._repo_view.set_name("rigo-view")

        self._notice_scrolled_view = self._builder.get_object(
            "noticeViewScrolledWindow")
        self._notice_view = self._builder.get_object("noticeViewVbox")
        self._notice_view.set_name("rigo-view")

        self._pref_scrolled_view = self._builder.get_object(
            "preferencesViewScrolledWindow")
        self._pref_view = self._builder.get_object("preferencesViewVbox")
        self._pref_view.set_name("rigo-view")

        self._group_scrolled_view = self._builder.get_object(
            "groupViewScrolledWindow")
        self._group_view = self._builder.get_object("groupViewVbox")
        self._group_view.set_name("rigo-view")

        self._search_entry = self._builder.get_object("searchEntry")
        self._search_entry_completion = self._builder.get_object(
            "searchEntryCompletion")
        self._search_entry_store = self._builder.get_object(
            "searchEntryStore")
        self._static_view = self._builder.get_object("staticViewVbox")
        self._notification = self._builder.get_object("notificationBox")
        self._bottom_notification = \
            self._builder.get_object("bottomNotificationBox")
        self._work_view = self._builder.get_object("workViewVbox")
        self._work_view.set_name("rigo-view")

        self._pref_button = self._builder.get_object(
            "prefButton")
        def _pref_button_activate(widget):
            self._change_view_state(
                RigoViewStates.PREFERENCES_VIEW_STATE)
        self._pref_button.connect(
            "clicked", _pref_button_activate)

        # Preferences model, view and controller
        self._pref_store = PreferencesListStore()
        self._view_pref = PreferencesTreeView(
            icons, PreferencesListStore.ICON_SIZE)
        self._pref_scrolled_view.add(self._view_pref)
        def _pref_queue_draw(*args):
            self._view_pref.queue_draw()
        self._pref_store.connect("redraw-request", _pref_queue_draw)
        self._pref_view_c = PreferenceViewController(
            self._pref_store, self._view_pref)

        self._app_view_c = ApplicationViewController(
            self._entropy, self._entropy_ws, self._pref_view_c,
            self._service, self._builder)

        self._view = AppTreeView(
            self._entropy, self._service, self._app_view_c, icons,
            True, AppListStore.ICON_SIZE, store=None)
        self._scrolled_view.add(self._view)
        self._view.set_scrolled_view(self._scrolled_view)

        self._app_store = AppListStore(
            self._entropy, self._entropy_ws,
            self._service, self._view, icons)
        def _queue_draw(*args):
            self._view.queue_draw()
        self._app_store.connect("redraw-request", _queue_draw)

        self._app_view_c.set_store(self._app_store)
        self._app_view_c.connect("application-show",
            self._on_application_show)

        # Configuration file updates model, view and controller
        self._config_store = ConfigUpdatesListStore()
        self._view_config = ConfigUpdatesTreeView(
            icons, ConfigUpdatesListStore.ICON_SIZE)
        self._config_scrolled_view.add(self._view_config)
        def _config_queue_draw(*args):
            self._view_config.queue_draw()
        self._config_store.connect("redraw-request", _config_queue_draw)
        self._config_view_c = ConfigUpdatesViewController(
            self._entropy, self._config_store, self._view_config)
        self._config_view_c.connect(
            "view-cleared", self._on_view_cleared)

        self._service.set_configuration_controller(self._config_view_c)

        # Repository model, view and controller
        self._repo_store = RepositoryListStore()
        self._view_repo = RepositoryTreeView(
            icons, RepositoryListStore.ICON_SIZE)
        self._repo_scrolled_view.add(self._view_repo)
        def _repo_queue_draw(*args):
            self._view_repo.queue_draw()
        self._repo_store.connect("redraw-request", _repo_queue_draw)
        self._repo_view_c = RepositoryViewController(
            self._pref_view_c, self._service, self._repo_store,
            self._view_repo)

        # NoticeBoard model, view and controller
        self._notice_store = NoticeBoardListStore()
        self._view_notice = NoticeBoardTreeView(
            icons, NoticeBoardListStore.ICON_SIZE)
        self._notice_scrolled_view.add(self._view_notice)
        def _notice_queue_draw(*args):
            self._view_notice.queue_draw()
        self._notice_store.connect("redraw-request", _notice_queue_draw)
        self._notice_view_c = NoticeBoardViewController(
            self._notice_store, self._view_notice)

        self._service.set_noticeboard_controller(self._notice_view_c)

        # Group model, view and controller
        self._group_store = GroupListStore()
        self._view_group = GroupTreeView(
            icons, GroupListStore.ICON_SIZE)
        self._group_scrolled_view.add(self._view_group)
        def _group_queue_draw(*args):
            self._view_group.queue_draw()
        self._group_store.connect("redraw-request", _group_queue_draw)
        self._group_view_c = GroupViewController(
            self._service, self._group_store,
            self._view_group, self._pref_view_c)

        self._welcome_box = WelcomeBox()

        settings = Gtk.Settings.get_default()
        settings.set_property("gtk-error-bell", False)
        # wire up the css provider to reconfigure on theme-changes
        self._window.connect("style-updated",
                                 self._on_style_updated,
                                 init_sc_css_provider,
                                 settings,
                                 Gdk.Screen.get_default(),
                                 DATA_DIR)

        # Force the initialization of the css provider asap.
        # This fixes a glitch with GTK 3.10
        init_sc_css_provider(
            self._window,
            settings,
            Gdk.Screen.get_default(),
            DATA_DIR)

        self._nc = UpperNotificationViewController(
            self._entropy, self._entropy_ws, self._notification)
        # Bottom NotificationBox controller.
        # Bottom notifications are only used for
        # providing Activity control to User during
        # the Activity itself.
        self._bottom_nc = BottomNotificationViewController(
            self._window, self._bottom_notification,
            self._pref_button)

        self._avc = ApplicationsViewController(
            self._activity_rwsem,
            self._entropy, self._entropy_ws,
            self._nc, self._bottom_nc, self._service,
            self._pref_view_c, icons, self._not_found_box,
            self._search_entry, self._search_entry_completion,
            self._search_entry_store, self._app_store, self._view)

        self._avc.connect("view-cleared", self._on_view_cleared)
        self._avc.connect("view-filled", self._on_view_filled)
        self._avc.connect("view-want-change", self._on_view_change)

        self._service.set_bottom_notification_controller(
            self._bottom_nc)

        self._app_view_c.set_notification_controller(self._nc)
        self._app_view_c.set_applications_controller(self._avc)

        self._config_view_c.set_notification_controller(self._nc)
        self._config_view_c.set_applications_controller(self._avc)

        self._repo_view_c.set_notification_controller(self._nc)
        self._repo_view_c.set_applications_controller(self._avc)

        self._notice_view_c.set_notification_controller(self._nc)
        self._notice_view_c.set_applications_controller(self._avc)

        self._group_view_c.set_applications_controller(self._avc)

        self._service.set_applications_controller(self._avc)
        self._service.set_application_controller(self._app_view_c)
        self._service.set_notification_controller(self._nc)

        self._service.connect("start-working", self._on_start_working)
        self._service.connect("repositories-updated",
                              self._on_repo_updated)
        self._service.connect("applications-managed",
                              self._on_applications_managed)

        self._work_view_c = WorkViewController(
            icons, self._service, self._work_view)
        self._service.set_work_controller(self._work_view_c)

        self._bottom_nc.connect("show-work-view", self._on_show_work_view)
        self._bottom_nc.connect("work-interrupt", self._on_work_interrupt)
Example #4
0
    def __init__(self):
        self._current_state_lock = False
        self._current_state = RigoViewStates.STATIC_VIEW_STATE
        self._state_transitions = {
            RigoViewStates.BROWSER_VIEW_STATE: (self._enter_browser_state,
                                                self._exit_browser_state),
            RigoViewStates.STATIC_VIEW_STATE: (self._enter_static_state,
                                               self._exit_static_state),
            RigoViewStates.APPLICATION_VIEW_STATE:
            (self._enter_application_state, self._exit_application_state),
            RigoViewStates.WORK_VIEW_STATE: (self._enter_work_state,
                                             self._exit_work_state),
            RigoViewStates.CONFUPDATES_VIEW_STATE:
            (self._enter_confupdates_state, self._exit_confupdates_state),
            RigoViewStates.NOTICEBOARD_VIEW_STATE:
            (self._enter_noticeboard_state, self._exit_noticeboard_state),
            RigoViewStates.PREFERENCES_VIEW_STATE:
            (self._enter_preferences_state, self._exit_preferences_state),
            RigoViewStates.REPOSITORY_VIEW_STATE:
            (self._enter_repository_state, self._exit_repository_state),
            RigoViewStates.GROUPS_VIEW_STATE: (self._enter_groups_state,
                                               self._exit_groups_state)
        }
        self._state_metadata = {
            RigoViewStates.BROWSER_VIEW_STATE: {
                "title": _("Search"),
            },
            RigoViewStates.STATIC_VIEW_STATE: {
                "title": _("Rigo Application Browser"),
            },
            RigoViewStates.APPLICATION_VIEW_STATE: {
                "title": _("Application"),
            },
            RigoViewStates.WORK_VIEW_STATE: {
                "title": _("Working Hard"),
            },
            RigoViewStates.CONFUPDATES_VIEW_STATE: {
                "title": _("Wake Up"),
            },
            RigoViewStates.NOTICEBOARD_VIEW_STATE: {
                "title": _("Important Stuff"),
            },
            RigoViewStates.PREFERENCES_VIEW_STATE: {
                "title": _("Breaking Stuff"),
            },
            RigoViewStates.REPOSITORY_VIEW_STATE: {
                "title": _("Repository Stuff"),
            },
            RigoViewStates.GROUPS_VIEW_STATE: {
                "title": _("Application Groups"),
            },
        }
        self._state_mutex = Lock()

        icons = get_sc_icon_theme(DATA_DIR)

        self._activity_rwsem = ReadersWritersSemaphore()

        # This relies on the fact that the installed packages repository
        # is lazily loaded (thus, schema update code is).
        self._entropy = Client()
        self._entropy_ws = EntropyWebService(self._entropy)

        preload_task = ParallelTask(self._entropy_ws.preload)
        preload_task.name = "PreloadEntropyWebService"
        preload_task.daemon = True
        preload_task.start()

        self._service = RigoServiceController(self, self._activity_rwsem,
                                              self._entropy, self._entropy_ws)

        app_handler = Rigo.RigoHandler(self, self._service)

        self._builder = Gtk.Builder()
        self._builder.add_from_file(os.path.join(DATA_DIR, "ui/gtk3/rigo.ui"))
        self._builder.connect_signals(app_handler)
        self._window = self._builder.get_object("rigoWindow")
        self._window.set_name("rigo-view")
        self._apps_view = self._builder.get_object("appsViewVbox")
        self._scrolled_view = self._builder.get_object(
            "appsViewScrolledWindow")
        self._app_view = self._builder.get_object("appViewScrollWin")
        self._app_view.set_name("rigo-view")
        self._app_view_port = self._builder.get_object("appViewVport")
        self._app_view_port.set_name("rigo-view")
        self._not_found_box = self._builder.get_object("appsViewNotFoundVbox")

        self._config_scrolled_view = self._builder.get_object(
            "configViewScrolledWindow")
        self._config_view = self._builder.get_object("configViewVbox")
        self._config_view.set_name("rigo-view")

        self._repo_scrolled_view = self._builder.get_object(
            "repoViewScrolledWindow")
        self._repo_view = self._builder.get_object("repoViewVbox")
        self._repo_view.set_name("rigo-view")

        self._notice_scrolled_view = self._builder.get_object(
            "noticeViewScrolledWindow")
        self._notice_view = self._builder.get_object("noticeViewVbox")
        self._notice_view.set_name("rigo-view")

        self._pref_scrolled_view = self._builder.get_object(
            "preferencesViewScrolledWindow")
        self._pref_view = self._builder.get_object("preferencesViewVbox")
        self._pref_view.set_name("rigo-view")

        self._group_scrolled_view = self._builder.get_object(
            "groupViewScrolledWindow")
        self._group_view = self._builder.get_object("groupViewVbox")
        self._group_view.set_name("rigo-view")

        self._search_entry = self._builder.get_object("searchEntry")
        self._search_entry_completion = self._builder.get_object(
            "searchEntryCompletion")
        self._search_entry_store = self._builder.get_object("searchEntryStore")
        self._static_view = self._builder.get_object("staticViewVbox")
        self._notification = self._builder.get_object("notificationBox")
        self._bottom_notification = \
            self._builder.get_object("bottomNotificationBox")
        self._work_view = self._builder.get_object("workViewVbox")
        self._work_view.set_name("rigo-view")

        self._pref_button = self._builder.get_object("prefButton")

        def _pref_button_activate(widget):
            self._change_view_state(RigoViewStates.PREFERENCES_VIEW_STATE)

        self._pref_button.connect("clicked", _pref_button_activate)

        # Preferences model, view and controller
        self._pref_store = PreferencesListStore()
        self._view_pref = PreferencesTreeView(icons,
                                              PreferencesListStore.ICON_SIZE)
        self._pref_scrolled_view.add(self._view_pref)

        def _pref_queue_draw(*args):
            self._view_pref.queue_draw()

        self._pref_store.connect("redraw-request", _pref_queue_draw)
        self._pref_view_c = PreferenceViewController(self._pref_store,
                                                     self._view_pref)

        self._app_view_c = ApplicationViewController(self._entropy,
                                                     self._entropy_ws,
                                                     self._pref_view_c,
                                                     self._service,
                                                     self._builder)

        self._view = AppTreeView(self._entropy,
                                 self._service,
                                 self._app_view_c,
                                 icons,
                                 True,
                                 AppListStore.ICON_SIZE,
                                 store=None)
        self._scrolled_view.add(self._view)
        self._view.set_scrolled_view(self._scrolled_view)

        self._app_store = AppListStore(self._entropy, self._entropy_ws,
                                       self._service, self._view, icons)

        def _queue_draw(*args):
            self._view.queue_draw()

        self._app_store.connect("redraw-request", _queue_draw)

        self._app_view_c.set_store(self._app_store)
        self._app_view_c.connect("application-show", self._on_application_show)

        # Configuration file updates model, view and controller
        self._config_store = ConfigUpdatesListStore()
        self._view_config = ConfigUpdatesTreeView(
            icons, ConfigUpdatesListStore.ICON_SIZE)
        self._config_scrolled_view.add(self._view_config)

        def _config_queue_draw(*args):
            self._view_config.queue_draw()

        self._config_store.connect("redraw-request", _config_queue_draw)
        self._config_view_c = ConfigUpdatesViewController(
            self._entropy, self._config_store, self._view_config)
        self._config_view_c.connect("view-cleared", self._on_view_cleared)

        self._service.set_configuration_controller(self._config_view_c)

        # Repository model, view and controller
        self._repo_store = RepositoryListStore()
        self._view_repo = RepositoryTreeView(icons,
                                             RepositoryListStore.ICON_SIZE)
        self._repo_scrolled_view.add(self._view_repo)

        def _repo_queue_draw(*args):
            self._view_repo.queue_draw()

        self._repo_store.connect("redraw-request", _repo_queue_draw)
        self._repo_view_c = RepositoryViewController(self._pref_view_c,
                                                     self._service,
                                                     self._repo_store,
                                                     self._view_repo)

        # NoticeBoard model, view and controller
        self._notice_store = NoticeBoardListStore()
        self._view_notice = NoticeBoardTreeView(icons,
                                                NoticeBoardListStore.ICON_SIZE)
        self._notice_scrolled_view.add(self._view_notice)

        def _notice_queue_draw(*args):
            self._view_notice.queue_draw()

        self._notice_store.connect("redraw-request", _notice_queue_draw)
        self._notice_view_c = NoticeBoardViewController(
            self._notice_store, self._view_notice)

        self._service.set_noticeboard_controller(self._notice_view_c)

        # Group model, view and controller
        self._group_store = GroupListStore()
        self._view_group = GroupTreeView(icons, GroupListStore.ICON_SIZE)
        self._group_scrolled_view.add(self._view_group)

        def _group_queue_draw(*args):
            self._view_group.queue_draw()

        self._group_store.connect("redraw-request", _group_queue_draw)
        self._group_view_c = GroupViewController(self._service,
                                                 self._group_store,
                                                 self._view_group,
                                                 self._pref_view_c)

        self._welcome_box = WelcomeBox()

        settings = Gtk.Settings.get_default()
        settings.set_property("gtk-error-bell", False)
        # wire up the css provider to reconfigure on theme-changes
        self._window.connect("style-updated", self._on_style_updated,
                             init_sc_css_provider, settings,
                             Gdk.Screen.get_default(), DATA_DIR)

        # Force the initialization of the css provider asap.
        # This fixes a glitch with GTK 3.10
        init_sc_css_provider(self._window, settings, Gdk.Screen.get_default(),
                             DATA_DIR)

        self._nc = UpperNotificationViewController(self._entropy,
                                                   self._entropy_ws,
                                                   self._notification)
        # Bottom NotificationBox controller.
        # Bottom notifications are only used for
        # providing Activity control to User during
        # the Activity itself.
        self._bottom_nc = BottomNotificationViewController(
            self._window, self._bottom_notification, self._pref_button)

        self._avc = ApplicationsViewController(
            self._activity_rwsem, self._entropy, self._entropy_ws, self._nc,
            self._bottom_nc, self._service, self._pref_view_c, icons,
            self._not_found_box, self._search_entry,
            self._search_entry_completion, self._search_entry_store,
            self._app_store, self._view)

        self._avc.connect("view-cleared", self._on_view_cleared)
        self._avc.connect("view-filled", self._on_view_filled)
        self._avc.connect("view-want-change", self._on_view_change)

        self._service.set_bottom_notification_controller(self._bottom_nc)

        self._app_view_c.set_notification_controller(self._nc)
        self._app_view_c.set_applications_controller(self._avc)

        self._config_view_c.set_notification_controller(self._nc)
        self._config_view_c.set_applications_controller(self._avc)

        self._repo_view_c.set_notification_controller(self._nc)
        self._repo_view_c.set_applications_controller(self._avc)

        self._notice_view_c.set_notification_controller(self._nc)
        self._notice_view_c.set_applications_controller(self._avc)

        self._group_view_c.set_applications_controller(self._avc)

        self._service.set_applications_controller(self._avc)
        self._service.set_application_controller(self._app_view_c)
        self._service.set_notification_controller(self._nc)

        self._service.connect("start-working", self._on_start_working)
        self._service.connect("repositories-updated", self._on_repo_updated)
        self._service.connect("applications-managed",
                              self._on_applications_managed)

        self._work_view_c = WorkViewController(icons, self._service,
                                               self._work_view)
        self._service.set_work_controller(self._work_view_c)

        self._bottom_nc.connect("show-work-view", self._on_show_work_view)
        self._bottom_nc.connect("work-interrupt", self._on_work_interrupt)