New Icons and fixed delete message button
This commit is contained in:
		
							parent
							
								
									48c2fd2e81
								
							
						
					
					
						commit
						365e39a20a
					
				| @ -3,7 +3,10 @@ | ||||
|   <gresource prefix="/com/jeffser/Alpaca"> | ||||
|     <file>style.css</file> | ||||
|     <file>style-dark.css</file> | ||||
|     <file alias="icons/scalable/status/library-symbolic.svg">icons/library-symbolic.svg</file> | ||||
|     <file alias="icons/scalable/status/paper-plane-symbolic.svg">icons/paper-plane-symbolic.svg</file> | ||||
|     <file alias="icons/scalable/status/globe-symbolic.svg">icons/globe-symbolic.svg</file> | ||||
|     <file alias="icons/scalable/status/controls-big-symbolic.svg">icons/controls-big-symbolic.svg</file> | ||||
|     <file preprocess="xml-stripblanks">window.ui</file> | ||||
|     <file preprocess="xml-stripblanks">gtk/help-overlay.ui</file> | ||||
|   </gresource> | ||||
|  | ||||
							
								
								
									
										2
									
								
								src/icons/controls-big-symbolic.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								src/icons/controls-big-symbolic.svg
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 16 16" width="16px"><g fill="#222222"><path d="m 4.550781 1 c -1.9375 0 -3.5 1.5625 -3.5 3.5 s 1.5625 3.5 3.5 3.5 h 7 c 1.941407 0 3.5 -1.5625 3.5 -3.5 s -1.558593 -3.5 -3.5 -3.5 z m 7 1 c 1.386719 0 2.5 1.113281 2.5 2.5 c 0 1.382812 -1.113281 2.5 -2.5 2.5 c -1.382812 0 -2.5 -1.117188 -2.5 -2.5 c 0 -1.386719 1.117188 -2.5 2.5 -2.5 z m 0 0"/><path d="m 4.550781 9 c -1.9375 0 -3.5 1.5625 -3.5 3.5 s 1.5625 3.5 3.5 3.5 h 7 c 1.941407 0 3.5 -1.5625 3.5 -3.5 s -1.558593 -3.5 -3.5 -3.5 z m 0 1 c 1.386719 0 2.5 1.113281 2.5 2.5 c 0 1.382812 -1.113281 2.5 -2.5 2.5 c -1.382812 0 -2.5 -1.117188 -2.5 -2.5 c 0 -1.386719 1.117188 -2.5 2.5 -2.5 z m 0 0" fill-opacity="0.35"/></g></svg> | ||||
| After Width: | Height: | Size: 785 B | 
							
								
								
									
										2
									
								
								src/icons/globe-symbolic.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								src/icons/globe-symbolic.svg
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 16 16" width="16px"><path d="m 7.5 0 c -4.128906 0 -7.5 3.371094 -7.5 7.5 s 3.371094 7.5 7.5 7.5 s 7.5 -3.371094 7.5 -7.5 s -3.371094 -7.5 -7.5 -7.5 z m 0 2 c 0.257812 0 0.503906 0.023438 0.75 0.054688 c 0.191406 0.261718 0.382812 0.59375 0.550781 1.027343 c 0.105469 0.277344 0.203125 0.585938 0.289063 0.917969 h -3.179688 c 0.085938 -0.332031 0.183594 -0.640625 0.289063 -0.917969 c 0.167969 -0.433593 0.359375 -0.765625 0.550781 -1.027343 c 0.246094 -0.03125 0.492188 -0.054688 0.75 -0.054688 z m -2.085938 0.40625 c -0.050781 0.109375 -0.105468 0.203125 -0.148437 0.316406 c -0.148437 0.386719 -0.269531 0.820313 -0.378906 1.277344 h -1.617188 c 0.570313 -0.691406 1.296875 -1.246094 2.144531 -1.59375 z m 4.171876 0 c 0.847656 0.347656 1.574218 0.902344 2.144531 1.59375 h -1.617188 c -0.109375 -0.457031 -0.230469 -0.890625 -0.378906 -1.277344 c -0.042969 -0.113281 -0.097656 -0.207031 -0.148437 -0.316406 z m -6.980469 2.59375 h 2.082031 c -0.097656 0.628906 -0.148438 1.300781 -0.167969 2 h -2.480469 c 0.0625 -0.714844 0.253907 -1.390625 0.566407 -2 z m 3.09375 0 h 3.601562 c 0.101563 0.617188 0.15625 1.292969 0.179688 2 h -3.960938 c 0.023438 -0.707031 0.078125 -1.382812 0.179688 -2 z m 4.613281 0 h 2.082031 c 0.3125 0.609375 0.503907 1.285156 0.566407 2 h -2.480469 c -0.019531 -0.699219 -0.070313 -1.371094 -0.167969 -2 z m -8.273438 3 h 2.480469 c 0.019531 0.699219 0.070313 1.375 0.167969 2 h -2.082031 c -0.3125 -0.609375 -0.503907 -1.285156 -0.566407 -2 z m 3.480469 0 h 3.960938 c -0.023438 0.707031 -0.078125 1.382812 -0.179688 2 h -3.601562 c -0.101563 -0.617188 -0.15625 -1.292969 -0.179688 -2 z m 4.960938 0 h 2.480469 c -0.0625 0.714844 -0.253907 1.390625 -0.566407 2 h -2.082031 c 0.097656 -0.625 0.148438 -1.300781 0.167969 -2 z m -7.210938 3 h 1.617188 c 0.109375 0.457031 0.230469 0.890625 0.378906 1.273438 c 0.042969 0.117187 0.097656 0.210937 0.148437 0.320312 c -0.847656 -0.347656 -1.574218 -0.902344 -2.144531 -1.59375 z m 2.640625 0 h 3.179688 c -0.085938 0.332031 -0.183594 0.640625 -0.289063 0.917969 c -0.167969 0.433593 -0.359375 0.765625 -0.550781 1.027343 c -0.246094 0.03125 -0.496094 0.054688 -0.75 0.054688 s -0.503906 -0.023438 -0.75 -0.054688 c -0.191406 -0.261718 -0.382812 -0.59375 -0.550781 -1.027343 c -0.105469 -0.277344 -0.203125 -0.585938 -0.289063 -0.917969 z m 4.203125 0 h 1.617188 c -0.570313 0.691406 -1.296875 1.246094 -2.144531 1.59375 c 0.050781 -0.109375 0.105468 -0.203125 0.148437 -0.320312 c 0.148437 -0.382813 0.269531 -0.816407 0.378906 -1.273438 z m 0 0" fill="#222222"/></svg> | ||||
| After Width: | Height: | Size: 2.6 KiB | 
							
								
								
									
										2
									
								
								src/icons/library-symbolic.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								src/icons/library-symbolic.svg
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 16 16" width="16px"><g fill="#222222"><path d="m 1.5 2 h 2 c 0.277344 0 0.5 0.222656 0.5 0.5 v 12 c 0 0.277344 -0.222656 0.5 -0.5 0.5 h -2 c -0.277344 0 -0.5 -0.222656 -0.5 -0.5 v -12 c 0 -0.277344 0.222656 -0.5 0.5 -0.5 z m 0 0"/><path d="m 5.5 4 h 1 c 0.277344 0 0.5 0.222656 0.5 0.5 v 10 c 0 0.277344 -0.222656 0.5 -0.5 0.5 h -1 c -0.277344 0 -0.5 -0.222656 -0.5 -0.5 v -10 c 0 -0.277344 0.222656 -0.5 0.5 -0.5 z m 0 0"/><path d="m 8.5 3 h 1 c 0.277344 0 0.5 0.222656 0.5 0.5 v 11 c 0 0.277344 -0.222656 0.5 -0.5 0.5 h -1 c -0.277344 0 -0.5 -0.222656 -0.5 -0.5 v -11 c 0 -0.277344 0.222656 -0.5 0.5 -0.5 z m 0 0"/><path d="m 10.707031 1.460938 l 0.964844 -0.261719 c 0.265625 -0.070313 0.539063 0.089843 0.613281 0.355469 l 3.363282 12.558593 c 0.070312 0.265625 -0.085938 0.539063 -0.351563 0.609375 l -0.96875 0.261719 c -0.265625 0.070313 -0.539063 -0.089844 -0.613281 -0.355469 l -3.363282 -12.554687 c -0.070312 -0.269531 0.085938 -0.542969 0.355469 -0.613281 z m 0 0"/></g></svg> | ||||
| After Width: | Height: | Size: 1.1 KiB | 
| @ -50,7 +50,6 @@ class AlpacaWindow(Adw.ApplicationWindow): | ||||
|     model_tweaks = {"temperature": 0.7, "seed": 0, "keep_alive": 5} | ||||
|     local_models = [] | ||||
|     pulling_models = {} | ||||
|     current_chat_elements = [] #Used for deleting | ||||
|     chats = {"chats": {_("New Chat"): {"messages": []}}, "selected_chat": "New Chat"} | ||||
|     attached_image = {"path": None, "base64": None} | ||||
| 
 | ||||
| @ -284,11 +283,11 @@ class AlpacaWindow(Adw.ApplicationWindow): | ||||
|             self.get_application().send_notification(None, notification) | ||||
| 
 | ||||
|     def delete_message(self, message_element): | ||||
|         message_index = self.current_chat_elements.index(message_element) | ||||
|         del self.chats["chats"][self.chats["selected_chat"]]["messages"][message_index] | ||||
|         self.chat_container.remove(message_element) | ||||
|         del self.current_chat_elements[message_index] | ||||
|         self.save_history() | ||||
|         message_index = int(message_element.get_name()) | ||||
|         if message_index < len(self.chats["chats"][self.chats["selected_chat"]]["messages"]): | ||||
|             self.chats["chats"][self.chats["selected_chat"]]["messages"][message_index] = None | ||||
|             self.chat_container.remove(message_element) | ||||
|             self.save_history() | ||||
| 
 | ||||
|     def show_message(self, msg:str, bot:bool, footer:str=None, image_base64:str=None): | ||||
|         message_text = Gtk.TextView( | ||||
| @ -342,12 +341,12 @@ class AlpacaWindow(Adw.ApplicationWindow): | ||||
|             message_box.append(image) | ||||
| 
 | ||||
|         message_box.append(message_text) | ||||
|         self.current_chat_elements.append(Gtk.Overlay(css_classes=["message"])) | ||||
|         self.current_chat_elements[-1].set_child(message_box) | ||||
|         overlay = Gtk.Overlay(css_classes=["message"], name=str(len(self.chats["chats"][self.chats["selected_chat"]]["messages"])-1)) | ||||
|         overlay.set_child(message_box) | ||||
| 
 | ||||
|         delete_button.connect("clicked", lambda button, element=self.current_chat_elements[-1]: self.delete_message(element)) | ||||
|         self.current_chat_elements[-1].add_overlay(delete_button) | ||||
|         self.chat_container.append(self.current_chat_elements[-1]) | ||||
|         delete_button.connect("clicked", lambda button, element=overlay: self.delete_message(element)) | ||||
|         overlay.add_overlay(delete_button) | ||||
|         self.chat_container.append(overlay) | ||||
| 
 | ||||
|         if bot: | ||||
|             self.bot_message = message_buffer | ||||
| @ -630,7 +629,7 @@ class AlpacaWindow(Adw.ApplicationWindow): | ||||
|                 subtitle = "Image recognition" if model_info["image"] else None | ||||
|             ) | ||||
|             link_button = Gtk.Button( | ||||
|                 icon_name = "web-browser-symbolic", | ||||
|                 icon_name = "globe-symbolic", | ||||
|                 vexpand = False, | ||||
|                 valign = 3, | ||||
|                 css_classes = ["success"] | ||||
| @ -654,12 +653,13 @@ class AlpacaWindow(Adw.ApplicationWindow): | ||||
|     def load_history_into_chat(self): | ||||
|         for widget in list(self.chat_container): self.chat_container.remove(widget) | ||||
|         for message in self.chats['chats'][self.chats["selected_chat"]]['messages']: | ||||
|             if message['role'] == 'user': | ||||
|                 self.show_message(message['content'], False, f"\n\n<small>{message['date']}</small>", message['images'][0] if 'images' in message and len(message['images']) > 0 else None) | ||||
|             else: | ||||
|                 self.show_message(message['content'], True, f"\n\n<small>{message['model']}\t|\t{message['date']}</small>") | ||||
|                 self.add_code_blocks() | ||||
|                 self.bot_message = None | ||||
|             if message: | ||||
|                 if message['role'] == 'user': | ||||
|                     self.show_message(message['content'], False, f"\n\n<small>{message['date']}</small>", message['images'][0] if 'images' in message and len(message['images']) > 0 else None) | ||||
|                 else: | ||||
|                     self.show_message(message['content'], True, f"\n\n<small>{message['model']}\t|\t{message['date']}</small>") | ||||
|                     self.add_code_blocks() | ||||
|                     self.bot_message = None | ||||
| 
 | ||||
|     def load_history(self): | ||||
|         if os.path.exists(os.path.join(self.config_dir, "chats.json")): | ||||
| @ -668,6 +668,9 @@ class AlpacaWindow(Adw.ApplicationWindow): | ||||
|                     self.chats = json.load(f) | ||||
|                     if "selected_chat" not in self.chats or self.chats["selected_chat"] not in self.chats["chats"]: self.chats["selected_chat"] = list(self.chats["chats"].keys())[0] | ||||
|                     if len(list(self.chats["chats"].keys())) == 0: self.chats["chats"][_("New Chat")] = {"messages": []} | ||||
|                     for chat_name, content in self.chats['chats'].items(): | ||||
|                         for i, content in enumerate(content['messages']): | ||||
|                             if not content: del self.chats['chats'][chat_name]['messages'][i] | ||||
|             except Exception as e: | ||||
|                 self.chats = {"chats": {_("New Chat"): {"messages": []}}, "selected_chat": _("New Chat")} | ||||
|             self.load_history_into_chat() | ||||
|  | ||||
| @ -103,7 +103,7 @@ | ||||
|                             <property name="tooltip-text" translatable="yes">Manage models</property> | ||||
|                             <child> | ||||
|                               <object class="AdwButtonContent"> | ||||
|                                 <property name="icon-name">view-more-horizontal-symbolic</property> | ||||
|                                 <property name="icon-name">controls-big-symbolic</property> | ||||
|                               </object> | ||||
|                             </child> | ||||
|                           </object> | ||||
| @ -242,7 +242,7 @@ | ||||
|                                 </style> | ||||
|                                 <child> | ||||
|                                   <object class="AdwButtonContent"> | ||||
|                                     <property name="icon-name">edit-delete-symbolic</property> | ||||
|                                     <property name="icon-name">media-playback-stop-symbolic</property> | ||||
|                                   </object> | ||||
|                                 </child> | ||||
|                               </object> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user