def pc_remove_button_exec(self, widget): # Remove a user from the pass_chats list pokeylogger.debug("[*] remove_button clicked") if 'user_selected' in self.selected: slctn = self.selected['user_selected'] lines = passchats.pc_readlines() with open(PASS_LIST, "w") as passlist: for idx, val in enumerate(lines): if val!=slctn: passlist.write(val + "\n") passlist.close() self.pc_list_refresh(widget) else: pokeylogger.debug("\t No user specified!") nf_win = InfoDialog(self, self.favicon, "No user specified", "Please specify a user to remove!") response = nf_win.run() nf_win.destroy()
def pc_section_widgets(self, hgt_widget): pokeylogger.debug('\tpc_section_widgets') # Pass Chats Section # pc_label (Section title label) hgt_widget.append(('pc_label', 'Pass Chats')) # pc_chats_combo widget (Combo Box) pc_chats_combo_values = [] pc_chats_combo_values.append('# of Chats') pc_chats_combo_values.extend(range(6)) hgt_widget.append(('pc_chats_combo', pc_chats_combo_values, 'The number of chats your\npass_chat message will show', ["changed", self.pc_chats_combo_changed])) # pc_msg_box widget (Entry Box) hgt_widget.append(('pc_msg_box', 'Custom Message', "Enter a custom message to the\nusers in your list")) # pc_chatlist_treeview (Selectable TreeView list) hgt_widget.append(('pc_chatlist_treeview', [line for line in passchats.pc_readlines()], 'Your list of agents to broadcast\nrequests to')) # pc_remove_button widget (Action Button) hgt_widget.append(('pc_remove_button', 'Remove User', 'Removes a user from your pass_chats list', ["clicked", self.pc_remove_button_exec])) # pc_ldap_box widget (Entry Box) hgt_widget.append(('pc_ldap_box', 'User LDAP', "Enter a user's LDAP username\nto add to your pass_chat list")) # pc_add_button widget (Action Button) hgt_widget.append(('pc_add_button', 'Add', 'Adds a user to your pass_chats list', ["clicked", self.pc_add_button_exec])) # pc_button widget (Action Button) hgt_widget.append(('pc_button', 'Broadcast', 'Broadcasts a pass_chat message to\nthe users in your list', ['clicked', self.pc_button_exec]))
def pc_list_refresh(self, widget): store = Gtk.ListStore(str) for item in passchats.pc_readlines(): store.append([item]) self.pc_chatlist_treeview.set_model(store)