Пример #1
0
    def add_user(self, user):

        if user in self.users:
            return

        # Request user status, speed and number of shared files
        self.core.watch_user(user, force_update=True)

        # Request user interests
        self.queue.append(slskmessages.UserInterests(user))

        self.users.add(user)
Пример #2
0
    def request_user_info(self, user, switch_page=True):

        self.add_user(user)
        self.show_user(user, switch_page)

        # Request user description, picture and queue information
        self.core.send_message_to_peer(user, slskmessages.UserInfoRequest(None))

        # Request user status, speed and number of shared files
        self.core.watch_user(user, force_update=True)

        # Request user interests
        self.queue.append(slskmessages.UserInterests(user))

        # Request user country
        self.set_user_country(user, self.core.get_user_country(user))
Пример #3
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)
        )
Пример #4
0
    def __init__(self, userinfos, user):

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

        # Build the window
        load_ui_elements(self,
                         os.path.join(self.frame.gui_dir, "ui", "userinfo.ui"))
        self.info_bar = InfoBar(self.InfoBar, Gtk.MessageType.INFO)

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

        self.hates_store = Gtk.ListStore(str)
        self.Hates.set_model(self.hates_store)

        cols = initialise_columns(
            None, self.Hates, ["hates", _("Hates"), 0, "text", None])
        cols["hates"].set_sort_column_id(0)

        self.hates_store.set_sort_column_id(0, Gtk.SortType.ASCENDING)

        self.likes_store = Gtk.ListStore(str)
        self.Likes.set_model(self.likes_store)

        cols = initialise_columns(
            None, self.Likes, ["likes", _("Likes"), 0, "text", None])
        cols["likes"].set_sort_column_id(0)

        self.likes_store.set_sort_column_id(0, Gtk.SortType.ASCENDING)

        self.tag_local = self.descr.get_buffer().create_tag()

        self.update_visuals()

        self.user_popup = popup = PopupMenu(self.frame)
        popup.setup_user_menu(user)
        popup.get_items()[_("Show User I_nfo")].set_visible(False)

        popup.append_item(("", None))
        popup.append_item(("#" + _("Close All Tabs"), popup.on_close_all_tabs,
                           self.userinfos))
        popup.append_item(("#" + _("_Close Tab"), self.on_close))

        self.likes_popup_menu = popup = PopupMenu(self.frame)
        popup.setup(("$" + _("I _Like This"),
                     self.frame.interests.on_like_recommendation),
                    ("$" + _("I _Dislike This"),
                     self.frame.interests.on_dislike_recommendation),
                    ("", None), ("#" + _("_Search For Item"),
                                 self.frame.interests.on_recommend_search))

        self.hates_popup_menu = popup = PopupMenu(self.frame)
        popup.setup(("$" + _("I _Like This"),
                     self.frame.interests.on_like_recommendation),
                    ("$" + _("I _Dislike This"),
                     self.frame.interests.on_dislike_recommendation),
                    ("", None), ("#" + _("_Search For Item"),
                                 self.frame.interests.on_recommend_search))

        self.image_menu = popup = PopupMenu(self.frame)
        popup.setup(("#" + _("Zoom 1:1"), self.make_zoom_normal),
                    ("#" + _("Zoom In"), self.make_zoom_in),
                    ("#" + _("Zoom Out"), self.make_zoom_out), ("", None),
                    ("#" + _("Save Picture"), self.on_save_picture))
Пример #5
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.SORT_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.SORT_ASCENDING)

        # Encoding Combobox
        self.Elist = {}
        self.encoding, m = EncodingsMenu(self.frame.np, "userencoding", user)
        self.EncodingStore = gtk.ListStore(gobject.TYPE_STRING,
                                           gobject.TYPE_STRING)
        self.Encoding.set_model(self.EncodingStore)

        cell = gtk.CellRendererText()
        self.Encoding.pack_start(cell, True)
        self.Encoding.add_attribute(cell, 'text', 0)

        cell2 = gtk.CellRendererText()
        self.Encoding.pack_start(cell2, False)
        self.Encoding.add_attribute(cell2, 'text', 1)

        for item in m:
            self.Elist[item[1]] = self.EncodingStore.append([item[1], item[0]])
            if self.encoding == item[1]:
                self.Encoding.set_active_iter(self.Elist[self.encoding])

        self.tag_local = self.makecolour(buffer, "chatremote")
        self.ChangeColours()

        self.InterestsExpander.connect("activate", self.ExpanderStatus)
        self.InformationExpander.connect("activate", self.ExpanderStatus)
        self.DescriptionExpander.connect("activate", self.ExpanderStatus)

        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))
Пример #6
0
    def __init__(self, userinfos, user, conn):
        self.wTree = gtk.glade.XML(
            os.path.join(os.path.dirname(os.path.realpath(__file__)),
                         "userinfo.glade"), None)
        widgets = self.wTree.get_widget_prefix("")
        for i in widgets:
            name = gtk.glade.get_widget_name(i)
            self.__dict__[name] = i
        self.UserInfoTab.remove(self.Main)
        self.UserInfoTab.destroy()
        self.wTree.signal_autoconnect(self)
        self.userinfos = userinfos
        self.frame = userinfos.frame
        #self.tooltips = self.frame.tooltips
        #if not self.frame.np.config.sections["ui"]["tooltips"]:
        #	self.tooltips.disable()
        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.SORT_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.SORT_ASCENDING)

        self.Elist = {}
        self.encoding, m = EncodingsMenu(self.frame.np, "userencoding", user)
        self.EncodingStore = gtk.ListStore(gobject.TYPE_STRING,
                                           gobject.TYPE_STRING)
        self.Encoding.set_size_request(100, -1)
        self.Encoding.set_model(self.EncodingStore)

        cell = gtk.CellRendererText()
        self.Encoding.pack_start(cell, True)
        self.Encoding.add_attribute(cell, 'text', 0)
        cell2 = gtk.CellRendererText()
        self.Encoding.pack_start(cell2, False)
        self.Encoding.add_attribute(cell2, 'text', 1)
        for item in m:
            self.Elist[item[1]] = self.EncodingStore.append([item[1], item[0]])
            if self.encoding == item[1]:
                self.Encoding.set_active_iter(self.Elist[self.encoding])

        self.tag_local = self.makecolour(buffer, "chatremote")
        self.ChangeColours()
        self.InterestsExpander.connect("activate", self.ExpanderStatus)
        self.InformationExpander.connect("activate", self.ExpanderStatus)
        self.DescriptionExpander.connect("activate", self.ExpanderStatus)
        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,
             gtk.STOCK_FIND),
        )
        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,
             gtk.STOCK_FIND),
        )
        self.Hates.connect("button_press_event", self.OnPopupHatesMenu)

        self.image_menu = popup = PopupMenu(self)
        popup.setup(
            ("#" + _("Zoom 1:1"), self.MakeZoomNormal, gtk.STOCK_ZOOM_100),
            ("#" + _("Zoom In"), self.MakeZoomIn, gtk.STOCK_ZOOM_IN),
            ("#" + _("Zoom Out"), self.MakeZoomOut, gtk.STOCK_ZOOM_OUT),
            ("", None),
            ("#" + _("Save Image"), self.OnSavePicture, gtk.STOCK_SAVE),
        )
Пример #7
0
    def __init__(self, userinfos, user):

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

        # Build the window
        load_ui_elements(self,
                         os.path.join(self.frame.gui_dir, "ui", "userinfo.ui"))
        self.info_bar = InfoBar(self.InfoBar, Gtk.MessageType.INFO)

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

        self.hates_store = Gtk.ListStore(str)
        self.Hates.set_model(self.hates_store)

        cols = initialise_columns(self.Hates, [_("Hates"), 0, "text"])
        cols[0].set_sort_column_id(0)

        self.hates_store.set_sort_column_id(0, Gtk.SortType.ASCENDING)

        self.likes_store = Gtk.ListStore(str)
        self.Likes.set_model(self.likes_store)

        cols = initialise_columns(self.Likes, [_("Likes"), 0, "text"])
        cols[0].set_sort_column_id(0)

        self.likes_store.set_sort_column_id(0, Gtk.SortType.ASCENDING)

        self.tag_local = self.descr.get_buffer().create_tag()

        self.update_visuals()

        self.user_popup = popup = PopupMenu(self.frame)
        popup.setup(("#" + _("Send _message"), popup.on_send_message),
                    ("#" + _("Show IP a_ddress"), popup.on_show_ip_address),
                    ("#" + _("Get user i_nfo"), popup.on_get_user_info),
                    ("#" + _("Brow_se files"), popup.on_browse_user),
                    ("#" + _("Gi_ve privileges"), popup.on_give_privileges),
                    ("#" + _("Client Version"), popup.on_version), ("", None),
                    ("$" + _("_Add user to list"), popup.on_add_to_list),
                    ("$" + _("_Ban this user"), popup.on_ban_user),
                    ("$" + _("_Ignore this user"), popup.on_ignore_user),
                    ("", None), ("#" + _("_Close this tab"), self.on_close))
        popup.set_user(user)

        self.likes_popup_menu = popup = PopupMenu(self.frame)
        popup.setup(("$" + _("I _like this"),
                     self.frame.interests.on_like_recommendation),
                    ("$" + _("I _don't like this"),
                     self.frame.interests.on_dislike_recommendation),
                    ("", None), ("#" + _("_Search for this item"),
                                 self.frame.interests.on_recommend_search))

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

        self.hates_popup_menu = popup = PopupMenu(self.frame)
        popup.setup(("$" + _("I _like this"),
                     self.frame.interests.on_like_recommendation),
                    ("$" + _("I _don't like this"),
                     self.frame.interests.on_dislike_recommendation),
                    ("", None), ("#" + _("_Search for this item"),
                                 self.frame.interests.on_recommend_search))

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

        self.image_menu = popup = PopupMenu(self.frame)
        popup.setup(("#" + _("Zoom 1:1"), self.make_zoom_normal),
                    ("#" + _("Zoom In"), self.make_zoom_in),
                    ("#" + _("Zoom Out"), self.make_zoom_out), ("", None),
                    ("#" + _("Save Picture"), self.on_save_picture))