Exemple #1
0
    def __init__(self, frame):

        self.frame = frame
        self.initphase = True  # don't respond to signals unless False
        self.config = frame.np.config

        builder = gtk.Builder()

        builder.set_translation_domain('nicotine')
        builder.add_from_file(
            os.path.join(os.path.dirname(os.path.realpath(__file__)), "ui",
                         "fastconfigure.ui"))

        self.window = builder.get_object("FastConfigureAssistant")
        builder.connect_signals(self)

        self.kids = {}

        for i in builder.get_objects():
            try:
                self.kids[gtk.Buildable.get_name(i)] = i
            except TypeError:
                pass

        numpages = self.window.get_n_pages()

        for n in range(numpages):
            page = self.window.get_nth_page(n)
            template = self.window.get_page_title(page)
            self.window.set_page_title(
                page, template % {
                    'page': (n + 1),
                    'pages': numpages
                })

        self.templates = {
            'listenport': self.kids['listenport'].get_text(),
        }

        # Page specific, sharepage
        # The last column is the raw byte/unicode object
        # for the folder (not shown)
        self.sharelist = gtk.ListStore(
            gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING,
            gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING,
            gobject.TYPE_STRING)

        columns = InitialiseColumns(  # noqa: F841
            self.kids['shareddirectoriestree'],
            [_("Virtual Directory"), 0, "text"], [_("Directory"), 0, "text"],
            [_("Size"), 0, "text"], [_("Files"), 0, "text"],
            [_("Dirs"), 0, "text"], [_("File types"), 0, "text"])

        self.kids['shareddirectoriestree'].set_model(self.sharelist)
        self.kids['shareddirectoriestree'].get_selection().set_mode(
            gtk.SelectionMode.MULTIPLE)

        self.initphase = False
Exemple #2
0
    def __init__(self, frame):

        self.frame = frame
        self.initphase = True  # don't respond to signals unless False
        self.config = frame.np.config

        builder = gtk.Builder()

        builder.set_translation_domain('nicotine')
        builder.add_from_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), "ui", "fastconfigure.ui"))

        self.window = builder.get_object("FastConfigureAssistant")
        self.window.set_transient_for(frame.MainWindow)
        builder.connect_signals(self)

        self.kids = {}

        for i in builder.get_objects():
            try:
                self.kids[gtk.Buildable.get_name(i)] = i
            except TypeError:
                pass

        # Page specific, sharepage
        # The last column is the raw byte/unicode object
        # for the folder (not shown)
        self.sharelist = gtk.ListStore(
            gobject.TYPE_STRING,
            gobject.TYPE_STRING,
            gobject.TYPE_STRING,
            gobject.TYPE_STRING,
            gobject.TYPE_STRING,
            gobject.TYPE_STRING,
            gobject.TYPE_STRING
        )

        InitialiseColumns(
            self.kids['shareddirectoriestree'],
            [_("Virtual Directory"), 0, "text"],
            [_("Directory"), 0, "text"],
            [_("Size"), 0, "text"],
            [_("Files"), 0, "text"],
            [_("Dirs"), 0, "text"],
            [_("File types"), 0, "text"]
        )

        self.kids['shareddirectoriestree'].set_model(self.sharelist)
        self.kids['shareddirectoriestree'].get_selection().set_mode(
            gtk.SelectionMode.MULTIPLE
        )

        self.initphase = False
Exemple #3
0
    def __init__(self, frame, searches):

        self.disconnected = False
        self.frame = frame
        self.interval = 0
        self.searches = searches
        self.timer = None
        self.wishes = {}

        builder = gtk.Builder()

        builder.set_translation_domain('nicotine')
        builder.add_from_file(
            os.path.join(os.path.dirname(os.path.realpath(__file__)), "ui",
                         "wishlist.ui"))

        self.WishList = builder.get_object("WishList")
        builder.connect_signals(self)

        for i in builder.get_objects():
            try:
                self.__dict__[gtk.Buildable.get_name(i)] = i
            except TypeError:
                pass

        self.WishList.set_transient_for(frame.MainWindow)

        self.WishList.connect("destroy", self.quit)
        self.WishList.connect("destroy-event", self.quit)
        self.WishList.connect("delete-event", self.quit)
        self.WishList.connect("delete_event", self.quit)

        self.store = gtk.ListStore(gobject.TYPE_STRING)

        cols = InitialiseColumns(self.WishlistView, [_("Wishes"), -1, "text"])

        self.WishlistView.set_model(self.store)
        self.WishlistView.get_selection().set_mode(gtk.SelectionMode.MULTIPLE)

        self.store.set_sort_column_id(0, gtk.SortType.ASCENDING)

        for wish in self.frame.np.config.sections["server"]["autosearch"]:
            self.wishes[wish] = self.store.append([wish])

        renderers = cols[0].get_cells()
        for render in renderers:
            render.set_property('editable', True)
            render.connect('edited', self.cell_edited_callback,
                           self.WishlistView, 0)

        self.frame.WishList.connect("clicked", self.show)
Exemple #4
0
    def __init__(self, userinfos, user, conn):

        # Build the window
        builder = gtk.Builder()

        builder.set_translation_domain('nicotine')
        builder.add_from_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), "ui", "userinfo.ui"))

        self.UserInfoTab = builder.get_object("UserInfoTab")

        for i in builder.get_objects():
            try:
                self.__dict__[gtk.Buildable.get_name(i)] = i
            except TypeError:
                pass

        self.UserInfoTab.remove(self.Main)
        self.UserInfoTab.destroy()

        builder.connect_signals(self)

        self.userinfos = userinfos
        self.frame = userinfos.frame

        self.frame.np.queue.put(slskmessages.UserInterests(user))
        self.user = user
        self.conn = conn
        self._descr = ""
        self.image_pixbuf = None
        self.zoom_factor = 5
        self.actual_zoom = 0
        self.status = 0

        self.hatesStore = gtk.ListStore(gobject.TYPE_STRING)
        self.Hates.set_model(self.hatesStore)
        cols = InitialiseColumns(self.Hates, [_("Hates"), 0, "text", self.CellDataFunc])
        cols[0].set_sort_column_id(0)
        self.hatesStore.set_sort_column_id(0, gtk.SortType.ASCENDING)

        self.likesStore = gtk.ListStore(gobject.TYPE_STRING)
        self.Likes.set_model(self.likesStore)
        cols = InitialiseColumns(self.Likes, [_("Likes"), 0, "text", self.CellDataFunc])
        cols[0].set_sort_column_id(0)
        self.likesStore.set_sort_column_id(0, gtk.SortType.ASCENDING)

        self.tag_local = self.makecolour("chatremote")  # noqa: F821
        self.ChangeColours()

        self.likes_popup_menu = popup = PopupMenu(self)
        popup.setup(
            ("$" + _("I _like this"), self.frame.OnLikeRecommendation),
            ("$" + _("I _don't like this"), self.frame.OnDislikeRecommendation),
            ("", None),
            ("#" + _("_Search for this item"), self.frame.OnRecommendSearch)
        )

        self.Likes.connect("button_press_event", self.OnPopupLikesMenu)

        self.hates_popup_menu = popup = PopupMenu(self)
        popup.setup(
            ("$" + _("I _like this"), self.frame.OnLikeRecommendation),
            ("$" + _("I _don't like this"), self.frame.OnDislikeRecommendation),
            ("", None),
            ("#" + _("_Search for this item"), self.frame.OnRecommendSearch)
        )

        self.Hates.connect("button_press_event", self.OnPopupHatesMenu)

        self.image_menu = popup = PopupMenu(self)
        popup.setup(
            ("#" + _("Zoom 1:1"), self.MakeZoomNormal),
            ("#" + _("Zoom In"), self.MakeZoomIn),
            ("#" + _("Zoom Out"), self.MakeZoomOut),
            ("", None),
            ("#" + _("Save Image"), self.OnSavePicture)
        )
Exemple #5
0
    def __init__(self, Searches, text, id, mode, remember, showtab):

        self.Searches = Searches
        self.frame = Searches.frame

        # Build the window
        builder = gtk.Builder()

        builder.set_translation_domain('nicotine')
        builder.add_from_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), "ui", "search.ui"))

        self.SearchTab = builder.get_object("SearchTab")

        for i in builder.get_objects():
            try:
                self.__dict__[gtk.Buildable.get_name(i)] = i
            except TypeError:
                pass

        self.SearchTab.remove(self.Main)
        self.SearchTab.destroy()

        builder.connect_signals(self)

        self.text = text
        self.searchterm_words_include = [p for p in text.lower().split() if not p.startswith('-')]
        self.searchterm_words_ignore = [p[1:] for p in text.lower().split() if p.startswith('-') and len(p) > 1]

        self.id = id
        self.mode = mode
        self.remember = remember
        self.showtab = showtab
        self.usersiters = {}
        self.directoryiters = {}
        self.users = set()
        self.all_data = []
        self.filters = None
        self.resultslimit = 2000
        self.numvisibleresults = 0

        self.operators = {
            '<': operator.lt,
            '<=': operator.le,
            '==': operator.eq,
            '!=': operator.ne,
            '>=': operator.ge,
            '>': operator.gt
        }

        FillFileGroupingCombobox(self.ResultGrouping)
        self.ResultGrouping.set_active(self.frame.np.config.sections["searches"]["group_searches"])
        self.ResultGrouping.connect("changed", self.OnGroup)

        self.ExpandButton.set_active(self.frame.np.config.sections["searches"]["expand_searches"])
        self.ExpandButton.connect("toggled", self.OnToggleExpandAll)

        if mode > 0:
            self.RememberCheckButton.set_sensitive(False)

        self.RememberCheckButton.set_active(remember)

        """ Columns """

        self.ResultsList.get_selection().set_mode(gtk.SelectionMode.MULTIPLE)
        self.ResultsList.set_enable_tree_lines(True)
        self.ResultsList.set_headers_clickable(True)
        self.ResultsList.set_rubber_banding(True)

        if self.ResultGrouping.get_active() > 0:
            # Group by folder or user

            self.ResultsList.set_show_expanders(True)
        else:
            self.ResultsList.set_show_expanders(False)

        self.resultsmodel = gtk.TreeStore(
            gobject.TYPE_UINT64,  # (0)  num
            str,                  # (1)  user
            gobject.TYPE_OBJECT,  # (2)  flag
            str,                  # (3)  immediatedl
            str,                  # (4)  h_speed
            str,                  # (5)  h_queue
            str,                  # (6)  directory
            str,                  # (7)  filename
            str,                  # (8)  h_size
            str,                  # (9)  h_bitrate
            str,                  # (10) length
            gobject.TYPE_UINT64,  # (11) bitrate
            str,                  # (12) fullpath
            str,                  # (13) country
            gobject.TYPE_UINT64,  # (14) size
            gobject.TYPE_UINT64,  # (15) speed
            gobject.TYPE_UINT64   # (16) queue
        )

        widths = self.frame.np.config.sections["columns"]["filesearch_widths"]
        cols = InitialiseColumns(
            self.ResultsList,
            [_("ID"), widths[0], "text", self.CellDataFunc],
            [_("User"), widths[1], "text", self.CellDataFunc],
            [_("Country"), widths[2], "pixbuf"],
            [_("Immediate Download"), widths[3], "center", self.CellDataFunc],
            [_("Speed"), widths[4], "number", self.CellDataFunc],
            [_("In queue"), widths[5], "center", self.CellDataFunc],
            [_("Directory"), widths[6], "text", self.CellDataFunc],
            [_("Filename"), widths[7], "text", self.CellDataFunc],
            [_("Size"), widths[8], "number", self.CellDataFunc],
            [_("Bitrate"), widths[9], "number", self.CellDataFunc],
            [_("Length"), widths[10], "number", self.CellDataFunc]
        )

        self.col_num, self.col_user, self.col_country, self.col_immediate, self.col_speed, self.col_queue, self.col_directory, self.col_file, self.col_size, self.col_bitrate, self.col_length = cols

        if self.ResultGrouping.get_active() > 0:
            # Group by folder or user

            self.ResultsList.get_columns()[0].set_visible(False)
            self.ExpandButton.show()

        HideColumns(cols, self.frame.np.config.sections["columns"]["filesearch_columns"])

        self.col_num.set_sort_column_id(0)
        self.col_user.set_sort_column_id(1)
        self.col_country.set_sort_column_id(13)
        self.col_immediate.set_sort_column_id(3)
        self.col_speed.set_sort_column_id(15)
        self.col_queue.set_sort_column_id(16)
        self.col_directory.set_sort_column_id(6)
        self.col_file.set_sort_column_id(7)
        self.col_size.set_sort_column_id(14)
        self.col_bitrate.set_sort_column_id(11)
        self.col_length.set_sort_column_id(10)

        self.col_country.get_widget().hide()

        self.ResultsList.set_model(self.resultsmodel)

        self.ResultsList.connect("button_press_event", self.OnListClicked)

        self.ChangeColours()

        """ Filters """

        self.FilterBitrate_List = gtk.ListStore(gobject.TYPE_STRING)
        self.FilterBitrate.set_model(self.FilterBitrate_List)
        self.FilterBitrate.set_entry_text_column(0)

        self.FilterSize_List = gtk.ListStore(gobject.TYPE_STRING)
        self.FilterSize.set_model(self.FilterSize_List)
        self.FilterSize.set_entry_text_column(0)

        self.FilterCountry_List = gtk.ListStore(gobject.TYPE_STRING)
        self.FilterCountry.set_model(self.FilterCountry_List)
        self.FilterCountry.set_entry_text_column(0)

        self.FilterIn_List = gtk.ListStore(gobject.TYPE_STRING)
        self.FilterIn.set_model(self.FilterIn_List)
        self.FilterIn.set_entry_text_column(0)

        self.FilterOut_List = gtk.ListStore(gobject.TYPE_STRING)
        self.FilterOut.set_model(self.FilterOut_List)
        self.FilterOut.set_entry_text_column(0)

        self.PopulateFilters()

        self.FilterSize.clear()
        sizecell = gtk.CellRendererText()
        sizecell.set_property("xalign", 1)
        self.FilterSize.pack_start(sizecell, True)
        self.FilterSize.add_attribute(sizecell, "text", 0)

        self.FilterBitrate.clear()
        bit_cell = gtk.CellRendererText()
        bit_cell.set_property("xalign", 1)
        self.FilterBitrate.pack_start(bit_cell, True)
        self.FilterBitrate.add_attribute(bit_cell, "text", 0)

        self.FilterIn.connect("changed", self.OnFilterChanged)
        self.FilterOut.connect("changed", self.OnFilterChanged)
        self.FilterSize.connect("changed", self.OnFilterChanged)
        self.FilterBitrate.connect("changed", self.OnFilterChanged)
        self.FilterCountry.connect("changed", self.OnFilterChanged)

        self.FilterIn.get_child().connect("activate", self.OnRefilter)
        self.FilterOut.get_child().connect("activate", self.OnRefilter)
        self.FilterSize.get_child().connect("activate", self.OnRefilter)
        self.FilterBitrate.get_child().connect("activate", self.OnRefilter)
        self.FilterCountry.get_child().connect("activate", self.OnRefilter)

        """ Popup """

        self.popup_menu_users = PopupMenu(self.frame, False)
        self.popup_menu = popup = PopupMenu(self.frame)
        popup.setup(
            ("#" + _("_Download file(s)"), self.OnDownloadFiles),
            ("#" + _("Download file(s) _to..."), self.OnDownloadFilesTo),
            ("#" + _("Download _folder(s)"), self.OnDownloadFolders),
            ("#" + _("Download f_older(s) to..."), self.OnDownloadFoldersTo),
            ("#" + _("View Metadata of file(s)"), self.OnSearchMeta),
            ("", None),
            ("#" + _("Copy _URL"), self.OnCopyURL),
            ("#" + _("Copy folder U_RL"), self.OnCopyDirURL),
            ("", None),
            (1, _("User(s)"), self.popup_menu_users, self.OnPopupMenuUsers)
        )
Exemple #6
0
    def __init__(self, userbrowses, user, conn):
        _config_dir, self.data_dir = GetUserDirectories()

        # Build the window
        builder = gtk.Builder()

        builder.set_translation_domain('nicotine')
        builder.add_from_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), "ui", "userbrowse.ui"))

        self.UserBrowseTab = builder.get_object("UserBrowseTab")

        for i in builder.get_objects():
            try:
                self.__dict__[gtk.Buildable.get_name(i)] = i
            except TypeError:
                pass

        self.UserBrowseTab.remove(self.Main)
        self.UserBrowseTab.destroy()

        builder.connect_signals(self)

        self.userbrowses = userbrowses

        self.frame = userbrowses.frame
        self.user = user
        self.conn = conn

        # selected_folder is the current selected folder
        self.selected_folder = None
        self.search_list = []
        self.query = None
        self.search_position = 0
        self.selected_files = []

        self.shares = []

        # Iters for current DirStore
        self.directories = {}

        # Iters for current FileStore
        self.files = {}
        self.totalsize = 0

        self.DirStore = gtk.TreeStore(str, str)

        self.FolderTreeView.set_headers_visible(True)
        self.FolderTreeView.set_enable_tree_lines(True)

        cols = InitialiseColumns(
            self.FolderTreeView,
            [_("Directories"), -1, "text", self.CellDataFunc]  # 0
        )
        cols[0].set_sort_column_id(0)

        self.popup_menu_users = PopupMenu(self.frame, False)
        self.popup_menu_users2 = PopupMenu(self.frame, False)
        for menu in [self.popup_menu_users, self.popup_menu_users2]:
            menu.setup(
                ("#" + _("Send _message"), menu.OnSendMessage),
                ("#" + _("Show IP a_ddress"), menu.OnShowIPaddress),
                ("#" + _("Get user i_nfo"), menu.OnGetUserInfo),
                ("#" + _("Gi_ve privileges"), menu.OnGivePrivileges),
                ("", None),
                ("$" + _("_Add user to list"), menu.OnAddToList),
                ("$" + _("_Ban this user"), menu.OnBanUser),
                ("$" + _("_Ignore this user"), menu.OnIgnoreUser)
            )

        self.popup_menu_downloads_folders = PopupMenu(self.frame, False)
        self.popup_menu_downloads_folders.setup(
            ("#" + _("_Download directory"), self.OnDownloadDirectory),
            ("#" + _("Download directory _to..."), self.OnDownloadDirectoryTo),
            ("#" + _("Download _recursive"), self.OnDownloadDirectoryRecursive),
            ("#" + _("Download r_ecursive to..."), self.OnDownloadDirectoryRecursiveTo)
        )

        self.popup_menu_downloads_files = PopupMenu(self.frame, False)
        self.popup_menu_downloads_files.setup(
            ("#" + _("_Download file(s)"), self.OnDownloadFiles),
            ("#" + _("Download _to..."), self.OnDownloadFilesTo),
            ("", None),
            ("#" + _("_Download directory"), self.OnDownloadDirectory),
            ("#" + _("Download directory _to..."), self.OnDownloadDirectoryTo),
            ("#" + _("Download _recursive"), self.OnDownloadDirectoryRecursive),
            ("#" + _("Download r_ecursive to..."), self.OnDownloadDirectoryRecursiveTo)
        )

        self.popup_menu_uploads_folders = PopupMenu(self.frame, False)
        self.popup_menu_uploads_folders.setup(
            ("#" + _("Upload Directory to..."), self.OnUploadDirectoryTo),
            ("#" + _("Upload Directory recursive to..."), self.OnUploadDirectoryRecursiveTo)
        )

        self.popup_menu_uploads_files = PopupMenu(self.frame, False)
        self.popup_menu_uploads_files.setup(
            ("#" + _("Upload Directory to..."), self.OnUploadDirectoryTo),
            ("#" + _("Upload Directory recursive to..."), self.OnUploadDirectoryRecursiveTo),
            ("#" + _("Up_load file(s)"), self.OnUploadFiles)
        )

        self.folder_popup_menu = PopupMenu(self.frame)
        self.folder_popup_menu.set_user(user)

        if user == self.frame.np.config.sections["server"]["login"]:
            self.folder_popup_menu.setup(
                ("USERMENU", _("User"), self.popup_menu_users, self.OnPopupMenuFolderUser),
                ("", None),
                (1, _("Download"), self.popup_menu_downloads_folders, self.OnPopupMenuDummy),
                (1, _("Upload"), self.popup_menu_uploads_folders, self.OnPopupMenuDummy),
                ("", None),
                ("#" + _("Copy _URL"), self.OnCopyDirURL),
                ("#" + _("Open in File Manager"), self.OnFileManager)
            )
        else:
            self.folder_popup_menu.setup(
                ("USERMENU", _("User"), self.popup_menu_users, self.OnPopupMenuFolderUser),
                ("", None),
                (1, _("Download"), self.popup_menu_downloads_folders, self.OnPopupMenuDummy),
                ("", None),
                ("#" + _("Copy _URL"), self.OnCopyDirURL)
            )

        self.FolderTreeView.connect("button_press_event", self.OnFolderClicked)
        self.FolderTreeView.get_selection().connect("changed", self.OnSelectDir)

        # Filename, HSize, Bitrate, HLength, Size, Length, RawFilename
        self.FileStore = gtk.ListStore(str, str, str, str, gobject.TYPE_INT64, int, str)

        self.FileTreeView.set_model(self.FileStore)
        widths = self.frame.np.config.sections["columns"]["userbrowse_widths"]
        cols = InitialiseColumns(
            self.FileTreeView,
            [_("Filename"), widths[0], "text", self.CellDataFunc],
            [_("Size"), widths[1], "text", self.CellDataFunc],
            [_("Bitrate"), widths[2], "text", self.CellDataFunc],
            [_("Length"), widths[3], "text", self.CellDataFunc]
        )
        cols[0].set_sort_column_id(0)
        cols[1].set_sort_column_id(4)
        cols[2].set_sort_column_id(2)
        cols[3].set_sort_column_id(5)
        self.FileStore.set_sort_column_id(0, gtk.SortType.ASCENDING)

        try:
            for i in range(len(cols)):

                parent = cols[i].get_widget().get_ancestor(gtk.Button)
                if parent:
                    parent.connect("button_press_event", PressHeader)

                # Read Show / Hide column settings from last session
                cols[i].set_visible(self.frame.np.config.sections["columns"]["userbrowse"][i])
        except IndexError:
            # Column count in config is probably incorrect (outdated?), don't crash
            pass

        self.FileTreeView.get_selection().set_mode(gtk.SelectionMode.MULTIPLE)
        self.FileTreeView.set_headers_clickable(True)
        self.FileTreeView.set_property("rules-hint", True)

        self.file_popup_menu = PopupMenu(self.frame)

        if user == self.frame.np.config.sections["server"]["login"]:
            self.file_popup_menu.setup(
                ("USERMENU", "User", self.popup_menu_users2, self.OnPopupMenuFileUser),
                ("", None),
                (1, _("Download"), self.popup_menu_downloads_files, self.OnPopupMenuDummy),
                (1, _("Upload"), self.popup_menu_uploads_files, self.OnPopupMenuDummy),
                ("", None),
                ("#" + _("Copy _URL"), self.OnCopyURL),
                ("#" + _("Send to _player"), self.OnPlayFiles),
                ("#" + _("Open in File Manager"), self.OnFileManager)
            )
        else:
            self.file_popup_menu.setup(
                ("USERMENU", "User", self.popup_menu_users2, self.OnPopupMenuFileUser),
                ("", None),
                (1, _("Download"), self.popup_menu_downloads_files, self.OnPopupMenuDummy),
                ("", None),
                ("#" + _("Copy _URL"), self.OnCopyURL)
            )

        self.FileTreeView.connect("button_press_event", self.OnFileClicked)

        self.ChangeColours()

        for name, object in list(self.__dict__.items()):
            if type(object) is PopupMenu:
                object.set_user(self.user)
    def __init__(self, frame, widget, type):
        self.frame = frame
        self.widget = widget
        self.type = type
        self.last_ui_update = self.last_save = time()
        self.list = None
        self.users = {}
        self.paths = {}

        # Status list
        self.statuses = {}
        self.statuses["Waiting for download"] = _("Waiting for download")
        self.statuses["Requesting file"] = _("Requesting file")
        self.statuses["Initializing transfer"] = _("Initializing transfer")
        self.statuses["Cannot connect"] = _("Cannot connect")
        self.statuses["Waiting for peer to connect"] = _(
            "Waiting for peer to connect")
        self.statuses["Connecting"] = _("Connecting")
        self.statuses["Getting address"] = _("Getting address")
        self.statuses["Getting status"] = _("Getting status")
        self.statuses["Queued"] = _("Queued")
        self.statuses["User logged off"] = _("User logged off")
        self.statuses["Aborted"] = _("Aborted")
        self.statuses["Finished"] = _("Finished")
        self.statuses["Paused"] = _("Paused")
        self.statuses["Transferring"] = _("Transferring")
        self.statuses["Filtered"] = _("Filtered")
        self.statuses["Connection closed by peer"] = _(
            "Connection closed by peer")
        self.statuses["File not shared"] = _("File not shared")
        self.statuses["File not shared."] = _(
            "File not shared"
        )  # The official client sends a variant containing a dot
        self.statuses["Establishing connection"] = _("Establishing connection")
        self.statuses["Download directory error"] = _(
            "Download directory error")
        self.statuses["Local file error"] = _("Local file error")
        self.statuses["Remote file error"] = _("Remote file error")

        # String templates
        self.extension_list_template = _("All %(ext)s")
        self.files_template = _("%(number)2s files ")

        widget.get_selection().set_mode(gtk.SelectionMode.MULTIPLE)
        widget.set_enable_tree_lines(True)
        widget.set_rubber_banding(True)

        self.transfersmodel = gtk.TreeStore(
            str,  # (0)  user
            str,  # (1)  path
            str,  # (2)  file name
            str,  # (3)  status
            str,  # (4)  hqueue position
            gobject.TYPE_UINT64,  # (5)  percent
            str,  # (6)  hsize
            str,  # (7)  hspeed
            str,  # (8)  htime elapsed
            str,  # (9)  time left
            str,  # (10) path
            str,  # (11) status (non-translated)
            gobject.TYPE_UINT64,  # (12) size
            gobject.TYPE_UINT64,  # (13) current bytes
            gobject.TYPE_UINT64,  # (14) speed
            gobject.TYPE_UINT64,  # (15) time elapsed
            gobject.TYPE_UINT64,  # (16) file count
            gobject.TYPE_UINT64,  # (17) queue position
        )

        text_color = self.frame.np.config.sections["ui"]["search"]

        widths = self.frame.np.config.sections["columns"]["{}_widths".format(
            type)]
        self.cols = cols = InitialiseColumns(
            widget,
            [_("User"), widths[0], "text", None, (text_color, None)],
            [_("Path"), widths[1], "text", None, (text_color, None)],
            [_("Filename"), widths[2], "text", None, (text_color, None)],
            [_("Status"), widths[3], "text", None, (text_color, None)],
            [
                _("Queue Position"), widths[4], "number", None,
                (text_color, None)
            ],
            [_("Percent"), widths[5], "progress"],
            [_("Size"), widths[6], "number", None, (text_color, None)],
            [_("Speed"), widths[7], "number", None, (text_color, None)],
            [_("Time elapsed"), widths[8], "number", None, (text_color, None)],
            [_("Time left"), widths[9], "number", None, (text_color, None)],
        )

        self.col_user, self.col_path, self.col_filename, self.col_status, self.col_position, self.col_percent, self.col_human_size, self.col_human_speed, self.col_time_elapsed, self.col_time_left = cols

        HideColumns(
            cols,
            self.frame.np.config.sections["columns"][self.type + "_columns"])

        self.col_user.set_sort_column_id(0)
        self.col_path.set_sort_column_id(1)
        self.col_filename.set_sort_column_id(2)
        self.col_status.set_sort_column_id(11)
        self.col_position.set_sort_column_id(17)
        self.col_percent.set_sort_column_id(5)
        self.col_human_size.set_sort_column_id(12)
        self.col_human_speed.set_sort_column_id(14)
        self.col_time_elapsed.set_sort_column_id(8)
        self.col_time_left.set_sort_column_id(9)

        widget.set_model(self.transfersmodel)

        widget.connect("button_press_event", self.OnPopupMenu, "mouse")
        widget.connect("key-press-event", self.on_key_press_event)

        self.UpdateColours()
Exemple #8
0
    def __init__(self, frame):

        # Build the window
        self.frame = frame
        config = self.frame.np.config.sections

        builder = gtk.Builder()

        builder.set_translation_domain('nicotine')
        builder.add_from_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), "ui", "buddylist.ui"))

        self.TempWindow = builder.get_object("TempWindow")

        for i in builder.get_objects():
            try:
                self.__dict__[gtk.Buildable.get_name(i)] = i
            except TypeError:
                pass

        self.TempWindow.remove(self.userlistvbox)
        self.TempWindow.destroy()

        builder.connect_signals(self)

        """ Columns """

        self.usersmodel = gtk.ListStore(
            gobject.TYPE_OBJECT,  # (0)  status icon
            gobject.TYPE_OBJECT,  # (1)  flag
            str,                  # (2)  username
            str,                  # (3)  hspeed
            str,                  # (4)  hfile count
            bool,                 # (5)  trusted
            bool,                 # (6)  notify
            bool,                 # (7)  privileged
            str,                  # (8)  hlast seen
            str,                  # (9)  comments
            gobject.TYPE_INT64,   # (10) status
            gobject.TYPE_UINT64,  # (11) speed
            gobject.TYPE_UINT64,  # (12) file count
            int,                  # (13) last seen
            str                   # (14) country
        )

        widths = self.frame.np.config.sections["columns"]["userlist_widths"]
        self.cols = cols = InitialiseColumns(
            self.UserList,
            [_("Status"), widths[0], "pixbuf"],
            [_("Country"), widths[1], "pixbuf"],
            [_("User"), widths[2], "text", self.CellDataFunc],
            [_("Speed"), widths[3], "number", self.CellDataFunc],
            [_("Files"), widths[4], "number", self.CellDataFunc],
            [_("Trusted"), widths[5], "toggle"],
            [_("Notify"), widths[6], "toggle"],
            [_("Privileged"), widths[7], "toggle"],
            [_("Last seen"), widths[8], "text", self.CellDataFunc],
            [_("Comments"), widths[9], "edit", self.CellDataFunc]
        )

        self.col_status, self.col_country, self.col_user, self.col_speed, self.col_files, self.col_trusted, self.col_notify, self.col_privileged, self.col_last_seen, self.col_comments = cols

        HideColumns(cols, config["columns"]["userlist"])

        self.col_status.set_sort_column_id(10)
        self.col_country.set_sort_column_id(14)
        self.col_user.set_sort_column_id(2)
        self.col_speed.set_sort_column_id(11)
        self.col_files.set_sort_column_id(12)
        self.col_trusted.set_sort_column_id(5)
        self.col_notify.set_sort_column_id(6)
        self.col_privileged.set_sort_column_id(7)
        self.col_last_seen.set_sort_column_id(13)
        self.col_comments.set_sort_column_id(9)

        self.col_status.get_widget().hide()
        self.col_country.get_widget().hide()

        if config["columns"]["hideflags"]:
            cols[1].set_visible(0)
            config["columns"]["userlist"][1] = 0

        for render in self.col_trusted.get_cells():
            render.connect('toggled', self.cell_toggle_callback, self.UserList, 5)

        for render in self.col_notify.get_cells():
            render.connect('toggled', self.cell_toggle_callback, self.UserList, 6)

        for render in self.col_privileged.get_cells():
            render.connect('toggled', self.cell_toggle_callback, self.UserList, 7)

        for render in self.col_comments.get_cells():
            render.connect('edited', self.cell_edited_callback, self.UserList, 9)

        self.UserList.set_model(self.usersmodel)

        """ Buddy list """

        for user in self.frame.np.config.sections["server"]["userlist"]:
            username, comment, notify, privileged, trusted, last_seen, country = user

            try:
                time_from_epoch = time.mktime(time.strptime(last_seen, "%m/%d/%Y %H:%M:%S"))
            except ValueError:
                last_seen = _("Never seen")
                time_from_epoch = 0

            row = [
                self.frame.GetStatusImage(0),
                self.frame.GetFlagImage(country),
                username,
                "",
                "",
                trusted,
                notify,
                privileged,
                last_seen,
                comment,
                0,
                0,
                0,
                time_from_epoch,
                country
            ]

            self.usersmodel.insert(0, row)

        self.usersmodel.set_sort_column_id(2, gtk.SortType.ASCENDING)

        """ Popup """

        self.Popup_Menu_PrivateRooms = PopupMenu(self.frame, False)
        self.popup_menu = popup = PopupMenu(frame)

        popup.setup(
            ("#" + _("Send _message"), popup.OnSendMessage),
            ("", None),
            ("#" + _("Show IP a_ddress"), popup.OnShowIPaddress),
            ("#" + _("Get user i_nfo"), popup.OnGetUserInfo),
            ("#" + _("Brow_se files"), popup.OnBrowseUser),
            ("#" + _("Gi_ve privileges"), popup.OnGivePrivileges),
            ("$" + _("_Ban this user"), popup.OnBanUser),
            ("$" + _("_Ignore this user"), popup.OnIgnoreUser),
            ("", None),
            ("$" + _("_Online notify"), self.OnNotify),
            ("$" + _("_Privileged"), self.OnPrivileged),
            ("$" + _("_Trusted"), self.OnTrusted),
            ("", None),
            ("#" + _("Edit _comments"), self.OnEditComments),
            ("#" + _("_Remove"), self.OnRemoveUser),
            (1, _("Private rooms"), self.Popup_Menu_PrivateRooms, popup.OnPrivateRooms)
        )

        items = self.popup_menu.get_children()
        self.Menu_SendMessage = items[0]
        self.Menu_ShowIPaddress = items[2]
        self.Menu_GetUserInfo = items[3]
        self.Menu_BrowseUser = items[4]
        self.Menu_GivePrivileges = items[5]
        self.Menu_BanUser = items[6]
        self.Menu_IgnoreUser = items[7]
        self.Menu_OnNotify = items[9]
        self.Menu_OnPrivileged = items[10]
        self.Menu_OnTrusted = items[11]
        self.Menu_EditComments = items[13]
        self.Menu_RemoveUser = items[14]
        self.Menu_PrivateRooms = items[15]

        self.UserList.connect("button_press_event", self.OnPopupMenu)
    def __init__(self, frame, widget, type):
        self.frame = frame
        self.widget = widget
        self.type = type
        self.list = None
        self.users = {}
        self.paths = {}
        self.lastupdate = 0
        self.finalupdatetimerid = None

        widget.get_selection().set_mode(gtk.SelectionMode.MULTIPLE)
        widget.set_enable_tree_lines(True)
        widget.set_rubber_banding(True)

        self.transfersmodel = gtk.TreeStore(
            str,                   # (0)  user
            str,                   # (1)  path
            str,                   # (2)  file name
            str,                   # (3)  status
            str,                   # (4)  hqueue position
            gobject.TYPE_UINT64,   # (5)  percent
            str,                   # (6)  hsize
            str,                   # (7)  hspeed
            str,                   # (8)  htime elapsed
            str,                   # (9)  time left
            str,                   # (10) path
            str,                   # (11) status (non-translated)
            gobject.TYPE_UINT64,   # (12) size
            gobject.TYPE_UINT64,   # (13) current bytes
            gobject.TYPE_UINT64,   # (14) speed
            gobject.TYPE_UINT64,   # (15) time elapsed
            gobject.TYPE_UINT64,   # (16) file count
            gobject.TYPE_UINT64,   # (17) queue position
        )

        widths = self.frame.np.config.sections["columns"]["{}_widths".format(type)]
        self.cols = cols = InitialiseColumns(
            widget,
            [_("User"), widths[0], "text", self.CellDataFunc],
            [_("Path"), widths[1], "text", self.CellDataFunc],
            [_("Filename"), widths[2], "text", self.CellDataFunc],
            [_("Status"), widths[3], "text", self.CellDataFunc],
            [_("Queue Position"), widths[4], "number", self.CellDataFunc],
            [_("Percent"), widths[5], "progress"],
            [_("Size"), widths[6], "number", self.CellDataFunc],
            [_("Speed"), widths[7], "number", self.CellDataFunc],
            [_("Time elapsed"), widths[8], "number", self.CellDataFunc],
            [_("Time left"), widths[9], "number", self.CellDataFunc]
        )

        self.col_user, self.col_path, self.col_filename, self.col_status, self.col_position, self.col_percent, self.col_human_size, self.col_human_speed, self.col_time_elapsed, self.col_time_left = cols

        HideColumns(cols, self.frame.np.config.sections["columns"][self.type + "_columns"])

        self.col_user.set_sort_column_id(0)
        self.col_path.set_sort_column_id(1)
        self.col_filename.set_sort_column_id(2)
        self.col_status.set_sort_column_id(11)
        self.col_position.set_sort_column_id(17)
        self.col_percent.set_sort_column_id(5)
        self.col_human_size.set_sort_column_id(12)
        self.col_human_speed.set_sort_column_id(14)
        self.col_time_elapsed.set_sort_column_id(8)
        self.col_time_left.set_sort_column_id(9)

        widget.set_model(self.transfersmodel)

        widget.connect("button_press_event", self.OnPopupMenu, "mouse")
        widget.connect("key-press-event", self.on_key_press_event)

        self.UpdateColours()
Exemple #10
0
    def __init__(self, frame, widget, type):
        self.frame = frame
        self.widget = widget
        self.type = type
        self.transfers = []
        self.list = None
        self.selected_transfers = []
        self.selected_users = []
        self.users = {}
        self.lastupdate = 0
        self.finalupdatetimerid = None
        widget.get_selection().set_mode(gtk.SelectionMode.MULTIPLE)

        columntypes = [
            gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING,
            gobject.TYPE_STRING, gobject.TYPE_UINT64, gobject.TYPE_STRING,
            gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING,
            gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_INT,
            gobject.TYPE_UINT64, gobject.TYPE_UINT64, gobject.TYPE_BOOLEAN,
            gobject.TYPE_STRING
        ]

        self.transfersmodel = gtk.TreeStore(*columntypes)
        widths = self.frame.np.config.sections["columns"]["{}_widths".format(
            type)]

        self.cols = cols = InitialiseColumns(
            widget, [_("User"), widths[0], "text", self.CellDataFunc],
            [_("Filename"), widths[1], "text", self.CellDataFunc],
            [_("Status"), widths[2], "text", self.CellDataFunc],
            [_("Queue Position"), widths[3], "text", self.CellDataFunc],
            [_("Percent"), widths[4], "progress"],
            [_("Size"), widths[5], "text", self.CellDataFunc],
            [_("Speed"), widths[6], "text", self.CellDataFunc],
            [_("Time elapsed"), widths[7], "text", self.CellDataFunc],
            [_("Time left"), widths[8], "text", self.CellDataFunc],
            [_("Path"), widths[9], "text", self.CellDataFunc])

        self.col_user, self.col_filename, self.col_status, self.col_position, self.col_percent, self.col_human_size, self.col_human_speed, self.col_time_elapsed, self.col_time_left, self.col_path = cols

        self.col_user.set_sort_column_id(0)
        self.col_filename.set_sort_column_id(1)
        self.col_status.set_sort_column_id(2)

        # Only view progress renderer on transfers, not user tree parents
        self.transfersmodel.set_sort_func(2, self.status_sort_func, 2)
        self.col_position.set_sort_column_id(3)
        self.transfersmodel.set_sort_func(3, int_sort_func, 3)
        self.col_percent.set_sort_column_id(11)

        self.col_percent.set_attributes(self.col_percent.get_cells()[0],
                                        value=4,
                                        visible=14)

        self.col_human_size.set_sort_column_id(12)
        self.col_human_speed.set_sort_column_id(6)
        self.col_time_elapsed.set_sort_column_id(7)
        self.col_time_left.set_sort_column_id(8)
        self.col_path.set_sort_column_id(9)

        self.transfersmodel.set_sort_func(11, self.progress_sort_func, 4)
        self.transfersmodel.set_sort_func(6, float_sort_func, 6)

        widget.set_model(self.transfersmodel)

        self.UpdateColours()
Exemple #11
0
    def __init__(self, frame):

        # Build the window
        self.frame = frame

        builder = gtk.Builder()

        builder.set_translation_domain('nicotine')
        builder.add_from_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), "ui", "buddylist.ui"))

        self.TempWindow = builder.get_object("TempWindow")

        for i in builder.get_objects():
            try:
                self.__dict__[gtk.Buildable.get_name(i)] = i
            except TypeError:
                pass

        self.TempWindow.remove(self.userlistvbox)
        self.TempWindow.destroy()

        builder.connect_signals(self)

        TARGETS = [('text/plain', 0, 1)]
        self.UserList.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK, TARGETS, Gdk.DragAction.COPY)
        self.UserList.enable_model_drag_dest(TARGETS, Gdk.DragAction.COPY)
        self.UserList.connect("drag_data_get", self.buddylist_drag_data_get_data)
        self.UserList.connect("drag_data_received", self.DragUserToBuddylist)

        self.userlist = []

        self.usersmodel = gtk.ListStore(
            gobject.TYPE_OBJECT, gobject.TYPE_OBJECT,
            gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING,
            gobject.TYPE_BOOLEAN, gobject.TYPE_BOOLEAN, gobject.TYPE_BOOLEAN,
            gobject.TYPE_STRING, gobject.TYPE_STRING,
            gobject.TYPE_INT, gobject.TYPE_INT, gobject.TYPE_INT, gobject.TYPE_INT,
            gobject.TYPE_STRING
        )
        widths = self.frame.np.config.sections["columns"]["userlist_widths"]
        self.cols = cols = InitialiseColumns(
            self.UserList,
            [_("Status"), widths[0], "pixbuf"],
            [_("Country"), widths[1], "pixbuf"],
            [_("User"), widths[2], "text", self.CellDataFunc],
            [_("Speed"), widths[3], "number", self.CellDataFunc],
            [_("Files"), widths[4], "number", self.CellDataFunc],
            [_("Trusted"), widths[5], "toggle"],
            [_("Notify"), widths[6], "toggle"],
            [_("Privileged"), widths[7], "toggle"],
            [_("Last seen"), widths[8], "text", self.CellDataFunc],
            [_("Comments"), widths[9], "edit", self.CellDataFunc]
        )

        self.col_status, self.col_country, self.col_user, self.col_speed, self.col_files, self.col_trusted, self.col_notify, self.col_privileged, self.col_last, self.col_comments = cols
        self.col_status.set_sort_column_id(10)
        self.col_country.set_sort_column_id(14)
        self.col_user.set_sort_column_id(2)
        self.col_speed.set_sort_column_id(11)
        self.col_files.set_sort_column_id(12)
        self.col_trusted.set_sort_column_id(5)
        self.col_notify.set_sort_column_id(6)
        self.col_privileged.set_sort_column_id(7)
        self.col_last.set_sort_column_id(13)
        self.col_comments.set_sort_column_id(9)
        self.col_status.get_widget().hide()
        self.col_country.get_widget().hide()

        config = self.frame.np.config.sections

        for i in range(10):

            parent = cols[i].get_widget().get_ancestor(gtk.Button)
            if parent:
                parent.connect('button_press_event', PressHeader)

            # Read Show / Hide column settings from last session
            cols[i].set_visible(config["columns"]["userlist"][i])

        if config["columns"]["hideflags"]:
            cols[1].set_visible(0)
            config["columns"]["userlist"][1] = 0

        for render in self.col_trusted.get_cells():
            render.connect('toggled', self.cell_toggle_callback, self.UserList, 5)

        for render in self.col_notify.get_cells():
            render.connect('toggled', self.cell_toggle_callback, self.UserList, 6)

        for render in self.col_privileged.get_cells():
            render.connect('toggled', self.cell_toggle_callback, self.UserList, 7)

        renderers = self.col_comments.get_cells()

        for render in renderers:
            render.connect('edited', self.cell_edited_callback, self.UserList, 9)

        self.UserList.set_model(self.usersmodel)
        self.UserList.set_property("rules-hint", True)
        self.privileged = []
        self.notify = []
        self.trusted = []

        for user in self.frame.np.config.sections["server"]["userlist"]:
            username, comment, notify, privileged, trusted, last_seen, flag = user

            if last_seen in ('', 'Never seen'):
                last_seen = _("Never seen")
                time_from_epoch = 0
            else:
                time_from_epoch = time.mktime(time.strptime(last_seen, "%m/%d/%Y %H:%M:%S"))

            row = [
                self.frame.GetStatusImage(0),
                self.frame.GetFlagImage(flag),
                username, "0", "0",
                trusted, notify, privileged, last_seen,
                comment, 0, 0, 0,
                time_from_epoch,
                flag
            ]

            if len(user) > 2:
                if notify:
                    self.notify.append(username)
                if privileged:
                    self.privileged.append(username)
                if trusted:
                    self.trusted.append(username)

            iter_ = self.usersmodel.insert(0, row)
            self.userlist.append([user[0], user[1], last_seen, iter_, flag])

        self.usersmodel.set_sort_column_id(2, gtk.SortType.ASCENDING)
        self.Popup_Menu_PrivateRooms = PopupMenu(self.frame)
        self.popup_menu = popup = PopupMenu(frame)

        popup.setup(
            ("#" + _("Send _message"), popup.OnSendMessage),
            ("", None),
            ("#" + _("Show IP a_ddress"), popup.OnShowIPaddress),
            ("#" + _("Get user i_nfo"), popup.OnGetUserInfo),
            ("#" + _("Brow_se files"), popup.OnBrowseUser),
            ("#" + _("Gi_ve privileges"), popup.OnGivePrivileges),
            ("$" + _("_Ban this user"), popup.OnBanUser),
            ("$" + _("_Ignore this user"), popup.OnIgnoreUser),
            ("", None),
            ("$" + _("_Online notify"), self.OnNotify),
            ("$" + _("_Privileged"), self.OnPrivileged),
            ("$" + _("_Trusted"), self.OnTrusted),
            ("", None),
            ("#" + _("Edit _comments"), self.OnEditComments),
            ("#" + _("_Remove"), self.OnRemoveUser),
            (1, _("Private rooms"), self.Popup_Menu_PrivateRooms, popup.OnPrivateRooms)
        )

        items = self.popup_menu.get_children()
        self.Menu_SendMessage = items[0]
        self.Menu_ShowIPaddress = items[2]
        self.Menu_GetUserInfo = items[3]
        self.Menu_BrowseUser = items[4]
        self.Menu_GivePrivileges = items[5]
        self.Menu_BanUser = items[6]
        self.Menu_IgnoreUser = items[7]
        self.Menu_OnNotify = items[9]
        self.Menu_OnPrivileged = items[10]
        self.Menu_OnTrusted = items[11]
        self.Menu_EditComments = items[13]
        self.Menu_RemoveUser = items[14]
        self.Menu_PrivateRooms = items[15]

        self.UserList.connect("button_press_event", self.OnPopupMenu)