Added new button to open file in default app
This commit is contained in:
		
							parent
							
								
									4a9349769a
								
							
						
					
					
						commit
						d457a1cfb8
					
				| @ -25,6 +25,7 @@ | ||||
|     <file alias="icons/scalable/status/play-symbolic.svg">icons/play-symbolic.svg</file> | ||||
|     <file alias="icons/scalable/status/step-back-symbolic.svg">icons/step-back-symbolic.svg</file> | ||||
|     <file alias="icons/scalable/status/step-over-symbolic.svg">icons/step-over-symbolic.svg</file> | ||||
|     <file alias="icons/scalable/status/share-symbolic.svg">icons/share-symbolic.svg</file> | ||||
|     <file preprocess="xml-stripblanks">window.ui</file> | ||||
|     <file preprocess="xml-stripblanks">gtk/help-overlay.ui</file> | ||||
|   </gresource> | ||||
|  | ||||
							
								
								
									
										2
									
								
								src/icons/share-symbolic.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								src/icons/share-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 6 h 1 c 0.257812 0 0.527344 -0.128906 0.71875 -0.3125 l 1.28125 -1.28125 v 6.59375 h 2 v -6.59375 l 1.28125 1.28125 c 0.191406 0.183594 0.410156 0.3125 0.71875 0.3125 h 1 v -1 c 0 -0.308594 -0.089844 -0.550781 -0.28125 -0.75 l -3.71875 -3.65625 l -3.71875 3.65625 c -0.191406 0.199219 -0.28125 0.441406 -0.28125 0.75 z m 0 0"/><path d="m 1.007812 11.972656 c 0 1.664063 1.367188 3.035156 3.03125 3.035156 h 7.917969 c 1.664063 0 3.03125 -1.371093 3.03125 -3.035156 v -1.972656 h -2 v 1.972656 c 0 0.589844 -0.441406 1.035156 -1.03125 1.035156 h -7.917969 c -0.589843 0 -1.03125 -0.445312 -1.03125 -1.035156 v -1.972656 h -2 z m 0 0"/><path d="m 4.039062 6.96875 c -1.664062 0 -3.03125 1.367188 -3.03125 3.03125 v 1.976562 h 2 v -1.976562 c 0 -0.589844 0.441407 -1.03125 1.03125 -1.03125 h 0.960938 v -2 z m 6.960938 0 v 2 h 0.957031 c 0.589844 0 1.03125 0.441406 1.03125 1.03125 v 1.976562 h 2 v -1.976562 c 0 -1.664062 -1.367187 -3.03125 -3.03125 -3.03125 z m 0 0"/></g></svg> | ||||
| After Width: | Height: | Size: 1.1 KiB | 
| @ -21,7 +21,7 @@ import gi | ||||
| gi.require_version('GtkSource', '5') | ||||
| gi.require_version('GdkPixbuf', '2.0') | ||||
| from gi.repository import Adw, Gtk, Gdk, GLib, GtkSource, Gio, GdkPixbuf | ||||
| import json, requests, threading, os, re, base64, sys, gettext, locale, webbrowser, subprocess, uuid, shutil, tarfile, tempfile #, docx | ||||
| import json, requests, threading, os, re, base64, sys, gettext, locale, subprocess, uuid, shutil, tarfile, tempfile #, docx | ||||
| from time import sleep | ||||
| from io import BytesIO | ||||
| from PIL import Image | ||||
| @ -103,6 +103,7 @@ class AlpacaWindow(Adw.ApplicationWindow): | ||||
|     manage_models_title = Gtk.Template.Child() | ||||
|     create_model_button = Gtk.Template.Child() | ||||
|     manage_models_back_button = Gtk.Template.Child() | ||||
|     file_preview_open_button = Gtk.Template.Child() | ||||
| 
 | ||||
|     manage_models_dialog = Gtk.Template.Child() | ||||
|     pulling_model_list_box = Gtk.Template.Child() | ||||
| @ -363,7 +364,7 @@ class AlpacaWindow(Adw.ApplicationWindow): | ||||
| 
 | ||||
|     @Gtk.Template.Callback() | ||||
|     def link_button_handler(self, button): | ||||
|         webbrowser.open(button.get_name()) | ||||
|         os.system(f'xdg-open "{button.get_name()}"') | ||||
| 
 | ||||
|     def check_alphanumeric(self, editable, text, length, position): | ||||
|         new_text = ''.join([char for char in text if char.isalnum() or char in ['-', '_']]) | ||||
| @ -436,8 +437,10 @@ class AlpacaWindow(Adw.ApplicationWindow): | ||||
|             buffer.insert(buffer.get_start_iter(), content, len(content)) | ||||
|             if file_type == 'youtube': | ||||
|                 self.file_preview_dialog.set_title(content.split('\n')[0]) | ||||
|                 self.file_preview_open_button.set_name(content.split('\n')[2]) | ||||
|             else: | ||||
|                 self.file_preview_dialog.set_title(os.path.basename(file_path)) | ||||
|                 self.file_preview_open_button.set_name(file_path) | ||||
|             self.file_preview_dialog.present(self) | ||||
| 
 | ||||
|     def convert_history_to_ollama(self): | ||||
| @ -910,7 +913,7 @@ class AlpacaWindow(Adw.ApplicationWindow): | ||||
|                 valign = 3, | ||||
|                 tooltip_text = _("Pull '{}'").format(name.capitalize()) | ||||
|             ) | ||||
|             link_button.connect("clicked", lambda button=link_button, link=model_info["url"]: webbrowser.open(link)) | ||||
|             link_button.connect("clicked", lambda button=link_button, link=model_info["url"]: os.system(f'xdg-open "{link}"')) | ||||
|             pull_button.connect("clicked", lambda button=pull_button, model_name=name: self.list_available_model_tags(model_name)) | ||||
|             model.add_suffix(link_button) | ||||
|             model.add_suffix(pull_button) | ||||
|  | ||||
| @ -391,6 +391,7 @@ | ||||
|                     <object class="GtkButton"> | ||||
|                       <signal name="clicked" handler="link_button_handler"/> | ||||
|                       <property name="name">https://github.com/ollama/ollama/blob/main/docs/gpu.md#overrides</property> | ||||
|                       <property name="tooltip-text">https://github.com/ollama/ollama/blob/main/docs/gpu.md#overrides</property> | ||||
|                       <property name="vexpand">false</property> | ||||
|                       <property name="valign">3</property> | ||||
|                       <property name="icon-name">globe-symbolic</property> | ||||
| @ -411,6 +412,7 @@ | ||||
|                     <object class="GtkButton"> | ||||
|                       <signal name="clicked" handler="link_button_handler"/> | ||||
|                       <property name="name">https://github.com/ollama/ollama/blob/main/docs/gpu.md#gpu-selection</property> | ||||
|                       <property name="tooltip-text">https://github.com/ollama/ollama/blob/main/docs/gpu.md#gpu-selection</property> | ||||
|                       <property name="vexpand">false</property> | ||||
|                       <property name="valign">3</property> | ||||
|                       <property name="icon-name">globe-symbolic</property> | ||||
| @ -431,6 +433,7 @@ | ||||
|                     <object class="GtkButton"> | ||||
|                       <signal name="clicked" handler="link_button_handler"/> | ||||
|                       <property name="name">https://github.com/ollama/ollama/blob/main/docs/gpu.md#gpu-selection-1</property> | ||||
|                       <property name="tooltip-text">https://github.com/ollama/ollama/blob/main/docs/gpu.md#gpu-selection-1</property> | ||||
|                       <property name="vexpand">false</property> | ||||
|                       <property name="valign">3</property> | ||||
|                       <property name="icon-name">globe-symbolic</property> | ||||
| @ -688,6 +691,15 @@ | ||||
|         <object class="AdwToolbarView"> | ||||
|           <child type="top"> | ||||
|             <object class="AdwHeaderBar"> | ||||
|               <child type="start"> | ||||
|                 <object class="GtkButton" id="file_preview_open_button"> | ||||
|                   <signal name="clicked" handler="link_button_handler"/> | ||||
|                   <property name="tooltip-text" translatable="yes">Open with Default App</property> | ||||
|                   <property name="vexpand">false</property> | ||||
|                   <property name="valign">3</property> | ||||
|                   <property name="icon-name">share-symbolic</property> | ||||
|                 </object> | ||||
|               </child> | ||||
|             </object> | ||||
|           </child> | ||||
|           <child> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user