[preview] Add Open Folder to context menu
This commit is contained in:
committed by
Philipp Hörist
parent
d9b146ee35
commit
0636307329
@@ -42,6 +42,7 @@ class UrlImagePreviewConfigDialog(SettingsDialog):
|
|||||||
actions = [
|
actions = [
|
||||||
('open_menuitem', _('Open')),
|
('open_menuitem', _('Open')),
|
||||||
('save_as_menuitem', _('Save as')),
|
('save_as_menuitem', _('Save as')),
|
||||||
|
('open_folder_menuitem', _('Open Folder')),
|
||||||
('copy_link_location_menuitem', _('Copy Link Location')),
|
('copy_link_location_menuitem', _('Copy Link Location')),
|
||||||
('open_link_in_browser_menuitem', _('Open Link in Browser')),
|
('open_link_in_browser_menuitem', _('Open Link in Browser')),
|
||||||
('open_file_in_browser_menuitem', _('Open File in Browser'))]
|
('open_file_in_browser_menuitem', _('Open File in Browser'))]
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Generated with glade 3.22.1 -->
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.0"/>
|
<requires lib="gtk+" version="3.0"/>
|
||||||
<object class="GtkImage" id="image1">
|
<object class="GtkImage" id="image1">
|
||||||
@@ -19,12 +20,17 @@
|
|||||||
<object class="GtkImage" id="image4">
|
<object class="GtkImage" id="image4">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="stock">gtk-jump-to</property>
|
<property name="icon_name">emblem-symbolic-link</property>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkImage" id="image5">
|
<object class="GtkImage" id="image5">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="stock">gtk-jump-to</property>
|
<property name="icon_name">emblem-symbolic-link</property>
|
||||||
|
</object>
|
||||||
|
<object class="GtkImage" id="image6">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="icon_name">folder-download</property>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkMenu" id="context_menu">
|
<object class="GtkMenu" id="context_menu">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
@@ -50,6 +56,17 @@
|
|||||||
<property name="always_show_image">True</property>
|
<property name="always_show_image">True</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImageMenuItem" id="open_folder_menuitem">
|
||||||
|
<property name="label" translatable="yes">Open _Folder</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<property name="image">image6</property>
|
||||||
|
<property name="use_stock">False</property>
|
||||||
|
<property name="always_show_image">True</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkSeparatorMenuItem" id="encryption_separator">
|
<object class="GtkSeparatorMenuItem" id="encryption_separator">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|||||||
@@ -26,7 +26,10 @@ from io import BytesIO
|
|||||||
import shutil
|
import shutil
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from gi.repository import Gtk, Gdk, GLib, GdkPixbuf
|
from gi.repository import Gtk
|
||||||
|
from gi.repository import Gdk
|
||||||
|
from gi.repository import GLib
|
||||||
|
from gi.repository import GdkPixbuf
|
||||||
|
|
||||||
from gajim.common import app
|
from gajim.common import app
|
||||||
from gajim.common import helpers
|
from gajim.common import helpers
|
||||||
@@ -39,7 +42,8 @@ from gajim.plugins import GajimPlugin
|
|||||||
from gajim.plugins.helpers import log_calls
|
from gajim.plugins.helpers import log_calls
|
||||||
from gajim.plugins.plugins_i18n import _
|
from gajim.plugins.plugins_i18n import _
|
||||||
|
|
||||||
from url_image_preview.http_functions import get_http_head, get_http_file
|
from url_image_preview.http_functions import get_http_head
|
||||||
|
from url_image_preview.http_functions import get_http_file
|
||||||
from url_image_preview.config_dialog import UrlImagePreviewConfigDialog
|
from url_image_preview.config_dialog import UrlImagePreviewConfigDialog
|
||||||
|
|
||||||
from gajim.gtk.filechoosers import FileSaveDialog
|
from gajim.gtk.filechoosers import FileSaveDialog
|
||||||
@@ -95,7 +99,7 @@ class UrlImagePreviewPlugin(GajimPlugin):
|
|||||||
(self.connect_with_history, self.disconnect_from_history),
|
(self.connect_with_history, self.disconnect_from_history),
|
||||||
'print_real_text': (self.print_real_text, None), }
|
'print_real_text': (self.print_real_text, None), }
|
||||||
self.config_default_values = {
|
self.config_default_values = {
|
||||||
'PREVIEW_SIZE': (150, 'Preview size(10-512)'),
|
'PREVIEW_SIZE': (150, 'Preview size (100-1000)'),
|
||||||
'MAX_FILE_SIZE': (5242880, 'Max file size for image preview'),
|
'MAX_FILE_SIZE': (5242880, 'Max file size for image preview'),
|
||||||
'ALLOW_ALL_IMAGES': (False, ''),
|
'ALLOW_ALL_IMAGES': (False, ''),
|
||||||
'LEFTCLICK_ACTION': ('open_menuitem', 'Open'),
|
'LEFTCLICK_ACTION': ('open_menuitem', 'Open'),
|
||||||
@@ -599,6 +603,7 @@ class Base(object):
|
|||||||
|
|
||||||
open_menuitem = xml.get_object('open_menuitem')
|
open_menuitem = xml.get_object('open_menuitem')
|
||||||
save_as_menuitem = xml.get_object('save_as_menuitem')
|
save_as_menuitem = xml.get_object('save_as_menuitem')
|
||||||
|
open_folder_menuitem = xml.get_object('open_folder_menuitem')
|
||||||
copy_link_location_menuitem = \
|
copy_link_location_menuitem = \
|
||||||
xml.get_object('copy_link_location_menuitem')
|
xml.get_object('copy_link_location_menuitem')
|
||||||
open_link_in_browser_menuitem = \
|
open_link_in_browser_menuitem = \
|
||||||
@@ -621,6 +626,9 @@ class Base(object):
|
|||||||
id_ = save_as_menuitem.connect(
|
id_ = save_as_menuitem.connect(
|
||||||
'activate', self.on_save_as_menuitem_activate_new, data)
|
'activate', self.on_save_as_menuitem_activate_new, data)
|
||||||
self.handlers[id_] = save_as_menuitem
|
self.handlers[id_] = save_as_menuitem
|
||||||
|
id_ = open_folder_menuitem.connect(
|
||||||
|
'activate', self._on_open_folder_menuitem_activate, data)
|
||||||
|
self.handlers[id_] = save_as_menuitem
|
||||||
id_ = copy_link_location_menuitem.connect(
|
id_ = copy_link_location_menuitem.connect(
|
||||||
'activate', self.on_copy_link_location_menuitem_activate, data)
|
'activate', self.on_copy_link_location_menuitem_activate, data)
|
||||||
self.handlers[id_] = copy_link_location_menuitem
|
self.handlers[id_] = copy_link_location_menuitem
|
||||||
@@ -661,6 +669,9 @@ class Base(object):
|
|||||||
file_name=original_filename,
|
file_name=original_filename,
|
||||||
transient_for=app.app.get_active_window())
|
transient_for=app.app.get_active_window())
|
||||||
|
|
||||||
|
def _on_open_folder_menuitem_activate(self, menu, data):
|
||||||
|
helpers.launch_file_manager(self.directory)
|
||||||
|
|
||||||
def on_copy_link_location_menuitem_activate(self, menu, data):
|
def on_copy_link_location_menuitem_activate(self, menu, data):
|
||||||
url = data["url"]
|
url = data["url"]
|
||||||
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
|
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
|
||||||
|
|||||||
Reference in New Issue
Block a user