Exemple #1
0
    def render_messages(self, messages, type, notify=True, local_user=False):
        # user to group \n messagebody \n time
        if len(messages) < 1:
            return
        message_body = (
            """\n<span foreground='red'><b>%s -> %s</b></span>\n%s\n<span foreground="dark gray"><i>%s</i></span>\n"""
        )
        for message in messages:
            if type == "Facebook":
                data_tuple = (
                    self.get_avatar(message["name"], facebook=message["pic_square"]),
                    message["name"],
                    "Facebook",
                    escape(message["status"]["message"]),
                    float(message["status"]["time"]),
                )
                self.db.add_new(data_tuple)
                func = self.messages_liststore.prepend
            elif type == "Check_Msg":
                data_tuple = (
                    self.get_avatar(message["user"]),
                    message["user"],
                    escape(message["group"]),
                    escape(message["data"]),
                    message["date"],
                )
                self.db.add_new(data_tuple)
                func = self.messages_liststore.prepend
            else:
                facebook = False if message[1] != "Facebook" else True
                data_tuple = (self.get_avatar(message[0], facebook), message[0], message[1], message[2], message[3])
                func = self.messages_liststore.append

            func(
                [
                    data_tuple[0],
                    message_body % (data_tuple[1], data_tuple[2], data_tuple[3], misc.nicetime(data_tuple[4])),
                    data_tuple[1],
                    data_tuple[4],
                ]
            )

        # if the user wants popups
        if self.preferences.popup and type != "DB" and local_user is False:
            self.notifier.new_message(data_tuple, len(messages), misc.nicetime(data_tuple[4]), data_tuple[0])
        if not self.main_window.is_active():
            self.notifier.set_icon(Settings.LOGO2)
Exemple #2
0
 def update_selection_view(self, dict, id=None):
     """called when the user creates a new snipplet"""
     row = self.db.return_most_recent_snipplet()
     row1 = gtk.gdk.pixbuf_new_from_file(self.parent.IMAGES_DIR + row[1].lower() + ".png")
     #if we have an id, it means it was an edited so dont add again just update
     if id:
         iter = self.selection_filter.convert_iter_to_child_iter(self.edit_iter)
         self.selection_liststore.remove(iter)
     row3 = nicetime(row[3])
     self.selection_liststore.prepend([row[0], row1, row[2], row3, row[4], row[1]])
Exemple #3
0
 def create_selection_area(self):
     self.selection_columns = ["id", "", "Description", "Modified", "Encryption", "Type"]
     self.selection_liststore = gtk.ListStore(int, gtk.gdk.Pixbuf, str, str, int, str)
     self.selection_filter = self.selection_liststore.filter_new()
     self.selection_view.set_model(self.selection_filter)
     snipplets = self.db.return_snipplet_selection()
     for row in snipplets:
         #id, type, description, modified, encryption
         row3 = nicetime(row[3])
         image = gtk.gdk.pixbuf_new_from_file(self.parent.IMAGES_DIR + row[1].lower() + ".png")
         self.selection_liststore.append([row[0], image, row[2], row3, row[4], row[1]])
             
     #append to columns
     i = 0
     for column in self.selection_columns:
         col = gtk.TreeViewColumn(column)
         if i == 1:
             cell = gtk.CellRendererPixbuf()
         else:    
             cell = gtk.CellRendererText()
         col.pack_start(cell, False)
         
         if i == 1:
             col.set_attributes(cell, pixbuf=i)
         else:
             col.set_attributes(cell, text=i)
         
         col.set_sizing(gtk.TREE_VIEW_COLUMN_GROW_ONLY)
         col.set_min_width(30)
         col.set_max_width(300)
         col.set_resizable(True)
         col.set_spacing(10)
         self.selection_view.append_column(col)
         if i == 0:
             col.set_visible(False)
         i +=1
     #show the last edited snipplet by default
     self.selection_filter.set_visible_func(self.check_selection_visibility)
     self.selection_view.get_selection().select_path(0)
     self.on_selection_cursor_changed(None)
Exemple #4
0
 def update_nicetimes(self):
     for row in self.messages_liststore:
         st = row[1].split("<i>")
         st[1] = """<i>%s</i></span>\n""" % misc.nicetime(row[3])
         row[1] = "".join(st)
     return True
Exemple #5
0
 def update_refresh_button(self):
     self.wTree.get_widget("refresh_label").set_text("Refresh (last done \n%s)" % nicetime(self.mtime))
     return True