コード例 #1
0
ファイル: GuiUtility.py プロジェクト: zzmjohn/tribler
    def RemoveFavorite(self, event, channel):
        if channel:
            if event:
                button = event.GetEventObject()
                button.Enable(False)
                if hasattr(button, 'selected'):
                    button.selected = False

            dlgname = 'RFdialog'
            if not self.ReadGuiSetting('show_%s' % dlgname, default=True):
                response = wx.ID_OK
            else:
                from Tribler.Main.Dialogs.ConfirmationDialog import ConfirmationDialog
                dlg = ConfirmationDialog(None, dlgname, "You are about to remove \'%s\' from your list of favourite channels." % channel.name,
                                         "If you remove this channel from your favourites, you will no longer be able to access its full content.")
                response = dlg.ShowModal()

            if response == wx.ID_OK:
                @forcePrioDBThread
                def remove_vote():
                    self.channelsearch_manager.remove_vote(channel.id)
                    wx.CallAfter(self.Notify, "Channel removed from favourites", "Removed channel '%s' from your favourites" % channel.name, icon='favourite')
                    if event:
                        button.Enable(True)
                    self.RefreshChannel(channel.id)
                remove_vote()
            elif event:
                button.Enable(True)
コード例 #2
0
ファイル: GuiUtility.py プロジェクト: xantares/tribler
    def RemoveSpam(self, event, channel):
        if channel:
            if event:
                button = event.GetEventObject()
                button.Enable(False)
                if hasattr(button, 'selected'):
                    button.selected = False

            dlgname = 'RSdialog'
            if not self.ReadGuiSetting('show_%s' % dlgname, default=True):
                response = wx.ID_OK
            else:
                from Tribler.Main.Dialogs.ConfirmationDialog import ConfirmationDialog
                dlg = ConfirmationDialog(
                    None, dlgname,
                    "You are about unmark channel \'%s\' as spam." %
                    channel.name, "")
                response = dlg.ShowModal()

            if response == wx.ID_OK:

                @forceDBThread
                def remove_vote():
                    self.channelsearch_manager.remove_vote(channel.id)
                    wx.CallAfter(
                        self.Notify, "Channel unmarked as spam",
                        "Channel '%s' unmarked as spam" % channel.name)
                    if event:
                        button.Enable(True)
                    self.RefreshChannel(channel.id)

                remove_vote()
            elif event:
                button.Enable(True)
コード例 #3
0
ファイル: GuiUtility.py プロジェクト: zzmjohn/tribler
    def MarkAsFavorite(self, event, channel):
        if channel:
            if event:
                button = event.GetEventObject()
                button.Enable(False)
                if hasattr(button, 'selected'):
                    button.selected = False

            dlgname = 'MFdialog'
            if not self.ReadGuiSetting('show_%s' % dlgname, default=True):
                response = wx.ID_OK
            else:
                from Tribler.Main.Dialogs.ConfirmationDialog import ConfirmationDialog
                dlg = ConfirmationDialog(None, dlgname, "You are about to add \'%s\' to your list of favourite channels." % channel.name,
                                         "If you mark this channel as your favourite, you will be able to access its full content.")
                response = dlg.ShowModal()

            if response == wx.ID_OK:
                @forcePrioDBThread
                def add_vote():
                    self.channelsearch_manager.favorite(channel.id)
                    wx.CallAfter(self.Notify, "Channel marked as favourite", "Marked channel '%s' as favourite" % channel.name, icon='favourite')
                    if event:
                        button.Enable(True)
                    UserEventLogDBHandler.getInstance().addEvent(message="User marked a channel as favorite", type=2)
                    self.RefreshChannel(channel.id)
                add_vote()
            elif event:
                button.Enable(True)
コード例 #4
0
ファイル: MainFrame.py プロジェクト: brussee/tribler
    def OnCloseWindow(self, event=None, force=False):
        found = False
        if event is not None:
            nr = event.GetEventType()
            lookup = {
                wx.EVT_CLOSE.evtType[0]: "EVT_CLOSE",
                wx.EVT_QUERY_END_SESSION.evtType[0]: "EVT_QUERY_END_SESSION",
                wx.EVT_END_SESSION.evtType[0]: "EVT_END_SESSION"
            }
            if nr in lookup:
                nr = lookup[nr]
                found = True

            self._logger.info("mainframe: Closing due to event %s %s", nr,
                              repr(event))
        else:
            self._logger.info("mainframe: Closing untriggered by event")

        # Don't do anything if the event gets called twice for some reason
        if self.utility.abcquitting:
            return

        # Check to see if we can veto the shutdown
        # (might not be able to in case of shutting down windows)
        if event is not None:
            try:
                if isinstance(event, wx.CloseEvent) and event.CanVeto(
                ) and self.utility.read_config(
                        'confirmonclose') and not event.GetEventType(
                        ) == wx.EVT_QUERY_END_SESSION.evtType[0]:
                    if self.shutdown_and_upgrade_notes:
                        confirmmsg = "Do you want to close Tribler and upgrade to the next version?  See release notes below" + \
                            "\n\n" + self.shutdown_and_upgrade_notes
                        confirmtitle = "Upgrade Tribler?"
                    else:
                        confirmmsg = "Do you want to close Tribler?"
                        confirmtitle = "Confirm"

                    dialog_name = 'closeconfirmation'
                    if not self.shutdown_and_upgrade_notes and not self.guiUtility.ReadGuiSetting(
                            'show_%s' % dialog_name, default=True):
                        result = wx.ID_OK
                    else:
                        dialog = ConfirmationDialog(None,
                                                    dialog_name,
                                                    confirmmsg,
                                                    title=confirmtitle)
                        result = dialog.ShowModal()
                        dialog.Destroy()

                    if result != wx.ID_OK:
                        event.Veto()

                        self._logger.info(
                            "mainframe: Not closing messagebox did not return OK"
                        )
                        return
            except:
                print_exc()

        self._logger.info('GUI closing')
        self.home.cancel_all_pending_tasks()
        if self.utility.session.get_creditmining_enable():
            self.creditminingpanel.cancel_all_pending_tasks()
            self.creditminingpanel.sourcelist.cancel_all_pending_tasks()
        self.utility.abcquitting = True
        self.GUIupdate = False

        if self.videoframe:
            self._logger.info("mainframe: Stopping internal player")

            self.videoframe.get_videopanel().Stop()

        try:
            self._logger.info("mainframe: Restoring from taskbar")

            # Restore the window before saving size and position
            # (Otherwise we'll get the size of the taskbar button and a negative position)
            self.onTaskBarActivate()
            self.saveWindowSettings()
        except:
            print_exc()

        if self.tbicon is not None:
            try:
                self._logger.info("mainframe: Removing tbicon")

                self.tbicon.RemoveIcon()
                self.tbicon.Destroy()
            except:
                print_exc()

        self._logger.info("mainframe: Calling quit")
        self.quit(event is not None or force)

        self._logger.debug("mainframe: OnCloseWindow END")
        ts = threading.enumerate()
        for t in ts:
            self._logger.info("mainframe: Thread still running %s daemon %s",
                              t.getName(), t.isDaemon())

        self._logger.info('GUI closed')