def _delete_logs(self, liststore, list_of_paths): paths_len = len(list_of_paths) if paths_len == 0: # nothing is selected return def on_ok(liststore, list_of_paths): # delete rows from db that match log_line_id list_of_rowrefs = [] for path in list_of_paths: # make them treerowrefs (it's needed) list_of_rowrefs.append(gtk.TreeRowReference(liststore, path)) for rowref in list_of_rowrefs: path = rowref.get_path() if path is None: continue log_line_id = liststore[path][0] del liststore[path] # remove from UI # remove from db self.cur.execute(''' DELETE FROM logs WHERE log_line_id = ? ''', (log_line_id,)) self.con.commit() self.AT_LEAST_ONE_DELETION_DONE = True pri_text = i18n.ngettext( 'Do you really want to delete the selected message?', 'Do you really want to delete the selected messages?', paths_len) dialogs.ConfirmationDialog(pri_text, _('This is an irreversible operation.'), on_response_ok = (on_ok, liststore, list_of_paths))
def _delete_logs(self, liststore, list_of_paths): paths_len = len(list_of_paths) if paths_len == 0: # nothing is selected return def on_ok(liststore, list_of_paths): # delete rows from db that match log_line_id list_of_rowrefs = [] for path in list_of_paths: # make them treerowrefs (it's needed) list_of_rowrefs.append(gtk.TreeRowReference(liststore, path)) for rowref in list_of_rowrefs: path = rowref.get_path() if path is None: continue log_line_id = liststore[path][0] del liststore[path] # remove from UI # remove from db self.cur.execute( ''' DELETE FROM logs WHERE log_line_id = ? ''', (log_line_id, )) self.con.commit() self.AT_LEAST_ONE_DELETION_DONE = True pri_text = i18n.ngettext( 'Do you really want to delete the selected message?', 'Do you really want to delete the selected messages?', paths_len) dialogs.ConfirmationDialog(pri_text, _('This is an irreversible operation.'), on_response_ok=(on_ok, liststore, list_of_paths))
def updateCounter(self): """ Display number of events on the top of window, sometimes it needs to be changed """ count = len(self.__class__.entries) if count: self.new_entry_label.set_text(i18n.ngettext( 'You have received new entries (and %d not displayed):', 'You have received new entries (and %d not displayed):', count, count, count)) self.next_button.set_sensitive(True) else: self.new_entry_label.set_text(_('You have received new entry:')) self.next_button.set_sensitive(False)
def updateCounter(self): """ Display number of events on the top of window, sometimes it needs to be changed """ count = len(self.__class__.entries) if count: self.new_entry_label.set_text( i18n.ngettext( 'You have received new entries (and %d not displayed):', 'You have received new entries (and %d not displayed):', count, count, count)) self.next_button.set_sensitive(True) else: self.new_entry_label.set_text(_('You have received new entry:')) self.next_button.set_sensitive(False)
def add_jid(self, jid, account, typ): systray.Systray.add_jid(self, jid, account, typ) nb = gajim.interface.roster.nb_unread for acct in gajim.connections: # in chat / groupchat windows for kind in ('chats', 'gc'): jids = gajim.interface.instances[acct][kind] for jid in jids: if jid != 'tabbed': nb += jids[jid].nb_unread[jid] text = i18n.ngettext( 'Gajim - %d unread message', 'Gajim - %d unread messages', nb, nb, nb) self.systray_winapi.notify_icon.set_tooltip(text)
def _delete_logs(self, liststore, list_of_paths): paths_len = len(list_of_paths) if paths_len == 0: # nothing is selected return def on_ok(liststore, list_of_paths): # delete rows from db that match log_line_id list_of_rowrefs = [] for path in list_of_paths: # make them treerowrefs (it's needed) list_of_rowrefs.append(gtk.TreeRowReference(liststore, path)) for rowref in list_of_rowrefs: path = rowref.get_path() if path is None: continue log_line_id = liststore[path][0] del liststore[path] # remove from UI # remove from db self.cur.execute( """ DELETE FROM logs WHERE log_line_id = ? """, (log_line_id,), ) self.con.commit() self.AT_LEAST_ONE_DELETION_DONE = True pri_text = i18n.ngettext( "Do you really want to delete the selected message?", "Do you really want to delete the selected messages?", paths_len, ) dialog = dialogs.ConfirmationDialog( pri_text, _("This is an irreversible operation."), on_response_ok=(on_ok, liststore, list_of_paths) ) dialog.set_title(_("Deletion Confirmation")) ok_button = dialog.get_children()[0].get_children()[1].get_children()[0] ok_button.grab_focus() dialog.set_transient_for(self.window)
def populate(self, data): self.create_window() self.create_table() self.hbox = gtk.HBox() self.table.set_property("column-spacing", 1) text, single_line = "", "" unread_chat = gajim.interface.roster.nb_unread unread_single_chat = 0 unread_gc = 0 unread_pm = 0 accounts = self.get_accounts_info() for acct in gajim.connections: # we count unread chat/pm messages chat_wins = gajim.interface.instances[acct]["chats"] for jid in chat_wins: if jid != "tabbed": if gajim.contacts[acct].has_key(jid): unread_chat += chat_wins[jid].nb_unread[jid] else: unread_pm += chat_wins[jid].nb_unread[jid] # we count unread gc/pm messages gc_wins = gajim.interface.instances[acct]["gc"] for jid in gc_wins: if jid != "tabbed": pm_msgs = gc_wins[jid].get_specific_unread(jid) unread_gc += gc_wins[jid].nb_unread[jid] unread_gc -= pm_msgs unread_pm += pm_msgs if unread_chat or unread_single_chat or unread_gc or unread_pm: text = "" if unread_chat: text += i18n.ngettext( "Gajim - %d unread message", "Gajim - %d unread messages", unread_chat, unread_chat, unread_chat ) text += "\n" if unread_single_chat: text += i18n.ngettext( "Gajim - %d unread single message", "Gajim - %d unread single messages", unread_single_chat, unread_single_chat, unread_single_chat, ) text += "\n" if unread_gc: text += i18n.ngettext( "Gajim - %d unread group chat message", "Gajim - %d unread group chat messages", unread_gc, unread_gc, unread_gc, ) text += "\n" if unread_pm: text += i18n.ngettext( "Gajim - %d unread private message", "Gajim - %d unread private messages", unread_pm, unread_pm, unread_pm, ) text += "\n" text = text[:-1] # remove latest \n elif len(accounts) > 1: text = _("Gajim") self.current_row = 1 self.table.resize(2, 1) self.fill_table_with_accounts(accounts) elif len(accounts) == 1: message = accounts[0]["status_line"] message = gtkgui_helpers.reduce_chars_newlines(message, 50, 1) message = gtkgui_helpers.escape_for_pango_markup(message) text = _("Gajim - %s") % message else: text = _("Gajim - %s") % helpers.get_uf_show("offline") self.text_label.set_markup(text) self.hbox.add(self.table) self.win.add(self.hbox)