Esempio n. 1
0
class SearchTweets(gtk.VBox):
    def __init__(self, mainwin, label=""):
        gtk.VBox.__init__(self, False)

        self.mainwin = mainwin
        self.input_topics = gtk.Entry()
        self.clearbtn = gtk.Button()
        self.clearbtn.set_image(self.mainwin.load_image("clear.png"))
        self.clearbtn.set_tooltip_text(_("Clear results"))
        try:
            # self.input_topics.set_property("primary-icon-stock",
            #                               gtk.STOCK_FIND)
            self.input_topics.set_property("secondary-icon-stock", gtk.STOCK_FIND)
            self.input_topics.connect("icon-press", self.__on_icon_press)
        except:
            pass

        inputbox = gtk.HBox(False)
        inputbox.pack_start(self.input_topics, True, True)
        inputbox.pack_start(self.clearbtn, False, False)

        self.topics = TweetList(mainwin, label)
        self.caption = label

        self.pack_start(inputbox, False, False)
        self.pack_start(self.topics, True, True)
        self.show_all()

        self.clearbtn.connect("clicked", self.__clear)
        self.input_topics.connect("activate", self.__search_topic)
        self.input_topics.grab_focus()

    def __on_icon_press(self, widget, pos, e):
        # if pos == 0:
        #    self.__search_topic(widget)
        if pos == 1:
            # widget.set_text('')
            self.__search_topic(widget)

    def __clear(self, widget):
        self.topics.clear()
        self.input_topics.grab_focus()

    def __search_topic(self, widget):
        topic = widget.get_text()
        if topic != "":
            self.mainwin.request_search_topic(topic)
            widget.set_text("")
        else:
            widget.set_text(_("You must write something to search"))
        widget.grab_focus()

    def update_tweets(self, arr_tweets):
        self.topics.update_tweets(arr_tweets)

    def update_user_pic(self, user, pic):
        self.topics.update_user_pic(user, pic)

    def update_wrap(self, width):
        self.topics.update_wrap(width)
Esempio n. 2
0
class ReplyBox(gtk.Window):
    def __init__(self, parent):
        gtk.Window.__init__(self)
        
        self.working = True
        self.mainwin = parent
        self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
        self.set_title(_('In reply to...'))
        self.set_resizable(False)
        self.set_size_request(400, 300)
        self.set_transient_for(parent)
        self.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        
        self.tweets = TweetList(parent, _('In reply to...'))
        
        top = gtk.VBox(False, 0)
        top.pack_start(self.tweets, True, True, 0)
        
        self.add(top)
        
        self.connect('delete-event', self.__unclose)
        self.connect('size-request', self.__size_request)
    
    def __size_request(self, widget, event, data=None):
        w, h = self.get_size()
        self.tweets.update_wrap(w)
        
    def __unclose(self, widget, event=None):
        if not self.working:
            self.hide()
        return True
        
    def show(self, twt_id, user):
        self.in_reply_id = twt_id
        self.in_reply_user = user
        self.set_title(_('In reply to %s') % user)
        self.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.tweets.clear()
        self.tweets.start_update()
        #self.tweets.waiting.stop(True)
        #self.tweets.lblerror.set_markup('<span background="#00FF00">Hola,
        # mi nombre es culero connoorrr</span>')
        self.show_all()
        
    def update(self, tweets):
        self.working = False
        if not tweets or (len(tweets) == 0): 
            self.tweets.stop_update(True, _('Oops... something went wrong'))
        else:
            self.tweets.stop_update()
            self.tweets.clear()
            self.tweets.update_tweets(tweets)
Esempio n. 3
0
class ReplyBox(gtk.Window):
    def __init__(self, parent):
        gtk.Window.__init__(self)

        self.working = True
        self.mainwin = parent
        self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
        self.set_title(_('In reply to...'))
        self.set_resizable(False)
        self.set_size_request(400, 300)
        self.set_transient_for(parent)
        self.set_position(gtk.WIN_POS_CENTER_ON_PARENT)

        self.tweets = TweetList(parent, _('In reply to...'))

        top = gtk.VBox(False, 0)
        top.pack_start(self.tweets, True, True, 0)

        self.add(top)

        self.connect('delete-event', self.__unclose)
        self.connect('size-request', self.__size_request)

    def __size_request(self, widget, event, data=None):
        w, h = self.get_size()
        self.tweets.update_wrap(w)

    def __unclose(self, widget, event=None):
        if not self.working:
            self.hide()
        return True

    def show(self, twt_id, user):
        self.in_reply_id = twt_id
        self.in_reply_user = user
        self.set_title(_('In reply to %s') % user)
        self.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.tweets.clear()
        self.tweets.start_update()
        self.show_all()

    def update(self, tweets):
        self.working = False
        if not tweets or (len(tweets) == 0):
            self.tweets.stop_update(True, _('Oops... something went wrong'))
        else:
            self.tweets.stop_update()
            self.tweets.clear()
            self.tweets.update_tweets(tweets)
Esempio n. 4
0
class SearchTweets(gtk.VBox):
    def __init__(self, mainwin, label=''):
        gtk.VBox.__init__(self, False)

        self.mainwin = mainwin
        self.input_topics = gtk.Entry()
        self.clearbtn = gtk.Button()
        self.clearbtn.set_image(self.mainwin.load_image('clear.png'))
        self.clearbtn.set_tooltip_text(_('Clear results'))
        try:
            #self.input_topics.set_property("primary-icon-stock",
            #                               gtk.STOCK_FIND)
            self.input_topics.set_property("secondary-icon-stock",
                                           gtk.STOCK_FIND)
            self.input_topics.connect("icon-press", self.__on_icon_press)
        except:
            pass

        inputbox = gtk.HBox(False)
        inputbox.pack_start(self.input_topics, True, True)
        inputbox.pack_start(self.clearbtn, False, False)

        self.topics = TweetList(mainwin, label)
        self.caption = label

        self.pack_start(inputbox, False, False)
        self.pack_start(self.topics, True, True)
        self.show_all()

        self.clearbtn.connect('clicked', self.__clear)
        self.input_topics.connect('activate', self.__search_topic)
        self.input_topics.grab_focus()

    def __on_icon_press(self, widget, pos, e):
        #if pos == 0:
        #    self.__search_topic(widget)
        if pos == 1:
            #widget.set_text('')
            self.__search_topic(widget)

    def __clear(self, widget):
        self.topics.clear()
        self.input_topics.grab_focus()

    def __search_topic(self, widget):
        topic = widget.get_text()
        if topic != '':
            self.mainwin.request_search_topic(topic)
            widget.set_text('')
        else:
            widget.set_text(_('You must write something to search'))
        widget.grab_focus()

    def update_tweets(self, arr_tweets):
        self.topics.update_tweets(arr_tweets)

    def update_user_pic(self, user, pic):
        self.topics.update_user_pic(user, pic)

    def update_wrap(self, width):
        self.topics.update_wrap(width)