Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gajim-plugins
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yuki
gajim-plugins
Commits
3fbc1b20
Commit
3fbc1b20
authored
Apr 23, 2019
by
Daniel Brötzmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[preview] Use Settings instead of Options
parent
d493646a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
91 deletions
+65
-91
url_image_preview/config_dialog.py
url_image_preview/config_dialog.py
+65
-91
No files found.
url_image_preview/config_dialog.py
View file @
3fbc1b20
...
...
@@ -20,115 +20,89 @@
from
gi.repository
import
GObject
from
gi.repository
import
Gtk
from
gajim.options_dialog
import
OptionsDialog
,
GenericOption
,
SpinOption
from
gajim.common.const
import
Option
,
OptionType
,
OptionKind
from
gajim.gtk.settings
import
SettingsDialog
from
gajim.gtk.settings
import
GenericSetting
from
gajim.gtk.settings
import
SpinSetting
from
gajim.gtk.const
import
Setting
from
gajim.gtk.const
import
SettingKind
from
gajim.gtk.const
import
SettingType
from
gajim.plugins.plugins_i18n
import
_
class
UrlImagePreviewConfigDialog
(
Option
sDialog
):
class
UrlImagePreviewConfigDialog
(
Setting
sDialog
):
def
__init__
(
self
,
plugin
,
parent
):
sizes
=
[(
'256 KiB'
,
'262144'
),
(
'512 KiB'
,
'524288'
),
(
'1 MiB'
,
'1048576'
),
(
'5 MiB'
,
'5242880'
),
(
'10 MiB'
,
'10485760'
)]
sizes
=
[(
'262144'
,
'256 KiB'
),
(
'524288'
,
'512 KiB'
),
(
'1048576'
,
'1 MiB'
),
(
'5242880'
,
'5 MiB'
),
(
'10485760'
,
'10 MiB'
)]
actions
=
[
(
_
(
'Open'
),
'open_menuitem'
),
(
_
(
'Save as'
),
'save_as_menuitem'
),
(
_
(
'Copy Link Location'
),
'copy_link_location_menuitem'
),
(
_
(
'Open Link in Browser'
),
'open_link_in_browser_menuitem'
),
(
_
(
'Open File in Browser'
),
'open_file_in_browser_menuitem'
)]
(
'open_menuitem'
,
_
(
'Open'
)
),
(
'save_as_menuitem'
,
_
(
'Save as'
)
),
(
'copy_link_location_menuitem'
,
_
(
'Copy Link Location'
)
),
(
'open_link_in_browser_menuitem'
,
_
(
'Open Link in Browser'
)
),
(
'open_file_in_browser_menuitem'
,
_
(
'Open File in Browser'
)
)]
geo_providers
=
[
(
_
(
'No map preview'
),
'no_preview'
),
(
'Google
Maps'
,
'Google'
),
(
'O
penStreetMap'
,
'OSM'
)]
(
'no_preview'
,
_
(
'No map preview'
)
),
(
'Google
'
,
_
(
'Google Maps'
)
),
(
'O
SM'
,
_
(
'OpenStreetMap'
)
)]
self
.
plugin
=
plugin
options
=
[
Option
(
'PreviewSizeSpinOption'
,
_
(
'Preview size'
),
OptionType
.
VALUE
,
self
.
plugin
.
config
[
'PREVIEW_SIZE'
],
callback
=
self
.
on_option
,
data
=
'PREVIEW_SIZE'
,
props
=
{
'range_'
:
(
100
,
1000
)}),
Option
(
'PreviewComboOption'
,
_
(
'Accepted filesize'
),
OptionType
.
VALUE
,
self
.
plugin
.
config
[
'MAX_FILE_SIZE'
],
callback
=
self
.
on_option
,
data
=
'MAX_FILE_SIZE'
,
props
=
{
'items'
:
sizes
,
'plugin'
:
self
.
plugin
}),
Option
(
OptionKind
.
SWITCH
,
_
(
'Preview all Image URLs'
),
OptionType
.
VALUE
,
self
.
plugin
.
config
[
'ALLOW_ALL_IMAGES'
],
callback
=
self
.
on_option
,
data
=
'ALLOW_ALL_IMAGES'
),
Option
(
'PreviewComboOption'
,
_
(
'Left click action'
),
OptionType
.
VALUE
,
self
.
plugin
.
config
[
'LEFTCLICK_ACTION'
],
callback
=
self
.
on_option
,
data
=
'LEFTCLICK_ACTION'
,
props
=
{
'items'
:
actions
,
'plugin'
:
self
.
plugin
}),
Option
(
'PreviewComboOption'
,
_
(
'Map service for preview'
),
OptionType
.
VALUE
,
self
.
plugin
.
config
[
'GEO_PREVIEW_PROVIDER'
],
callback
=
self
.
on_option
,
data
=
'GEO_PREVIEW_PROVIDER'
,
props
=
{
'items'
:
geo_providers
,
'plugin'
:
self
.
plugin
}),
Option
(
OptionKind
.
SWITCH
,
_
(
'Enable HTTPS Verification'
),
OptionType
.
VALUE
,
self
.
plugin
.
config
[
'VERIFY'
],
callback
=
self
.
on_option
,
data
=
'VERIFY'
),
settings
=
[
Setting
(
'PreviewSizeSpinSetting'
,
_
(
'Preview Size'
),
SettingType
.
VALUE
,
self
.
plugin
.
config
[
'PREVIEW_SIZE'
],
callback
=
self
.
on_setting
,
data
=
'PREVIEW_SIZE'
,
desc
=
_
(
'Size of preview image'
),
props
=
{
'range_'
:
(
100
,
1000
)}),
Setting
(
SettingKind
.
COMBO
,
_
(
'File Size'
),
SettingType
.
VALUE
,
self
.
plugin
.
config
[
'MAX_FILE_SIZE'
],
callback
=
self
.
on_setting
,
data
=
'MAX_FILE_SIZE'
,
desc
=
_
(
'Maximum file size for preview generation'
),
props
=
{
'combo_items'
:
sizes
}),
Setting
(
SettingKind
.
SWITCH
,
_
(
'Preview all Image URLs'
),
SettingType
.
VALUE
,
self
.
plugin
.
config
[
'ALLOW_ALL_IMAGES'
],
callback
=
self
.
on_setting
,
data
=
'ALLOW_ALL_IMAGES'
,
desc
=
_
(
'Generate preview for any URL containing images '
'(may be unsafe)'
)),
Setting
(
SettingKind
.
COMBO
,
_
(
'Left Click'
),
SettingType
.
VALUE
,
self
.
plugin
.
config
[
'LEFTCLICK_ACTION'
],
callback
=
self
.
on_setting
,
data
=
'LEFTCLICK_ACTION'
,
desc
=
_
(
'Action when left clicking a preview'
),
props
=
{
'combo_items'
:
actions
}),
Setting
(
SettingKind
.
COMBO
,
_
(
'Map Service'
),
SettingType
.
VALUE
,
self
.
plugin
.
config
[
'GEO_PREVIEW_PROVIDER'
],
callback
=
self
.
on_setting
,
data
=
'GEO_PREVIEW_PROVIDER'
,
desc
=
_
(
'Service used for map previews'
),
props
=
{
'combo_items'
:
geo_providers
}),
Setting
(
SettingKind
.
SWITCH
,
_
(
'HTTPS Verification'
),
SettingType
.
VALUE
,
self
.
plugin
.
config
[
'VERIFY'
],
desc
=
_
(
'Whether to check for a valid certificate'
),
callback
=
self
.
on_setting
,
data
=
'VERIFY'
),
]
OptionsDialog
.
__init__
(
self
,
parent
,
_
(
'UrlImagePreview Options
'
),
Gtk
.
DialogFlags
.
MODAL
,
option
s
,
None
,
SettingsDialog
.
__init__
(
self
,
parent
,
_
(
'UrlImagePreview Configuration
'
),
Gtk
.
DialogFlags
.
MODAL
,
setting
s
,
None
,
extend
=
[
(
'PreviewComboOption'
,
ComboOption
),
(
'PreviewSizeSpinOption'
,
SizeSpinOption
)])
(
'PreviewSizeSpinSetting'
,
SizeSpinSetting
)])
def
on_
option
(
self
,
value
,
data
):
def
on_
setting
(
self
,
value
,
data
):
self
.
plugin
.
config
[
data
]
=
value
class
SizeSpin
Option
(
SpinOption
):
class
SizeSpin
Setting
(
SpinSetting
):
__gproperties__
=
{
"
option
-value"
:
(
int
,
'Size'
,
''
,
100
,
1000
,
300
,
GObject
.
ParamFlags
.
READWRITE
),
}
"
setting
-value"
:
(
int
,
'Size'
,
''
,
100
,
1000
,
300
,
GObject
.
ParamFlags
.
READWRITE
),
}
def
__init__
(
self
,
*
args
,
**
kwargs
):
SpinOption
.
__init__
(
self
,
*
args
,
**
kwargs
)
class
ComboOption
(
GenericOption
):
__gproperties__
=
{
"option-value"
:
(
str
,
'Value'
,
''
,
''
,
GObject
.
ParamFlags
.
READWRITE
),
}
def
__init__
(
self
,
*
args
,
items
,
plugin
):
GenericOption
.
__init__
(
self
,
*
args
)
self
.
plugin
=
plugin
self
.
combo
=
Gtk
.
ComboBox
()
text_renderer
=
Gtk
.
CellRendererText
()
self
.
combo
.
pack_start
(
text_renderer
,
True
)
self
.
combo
.
add_attribute
(
text_renderer
,
'text'
,
0
)
self
.
store
=
Gtk
.
ListStore
(
str
,
str
)
for
item
in
items
:
self
.
store
.
append
(
item
)
self
.
combo
.
set_model
(
self
.
store
)
self
.
combo
.
set_id_column
(
1
)
self
.
combo
.
set_active_id
(
str
(
self
.
option_value
))
self
.
combo
.
connect
(
'changed'
,
self
.
on_value_change
)
self
.
combo
.
set_valign
(
Gtk
.
Align
.
CENTER
)
self
.
option_box
.
pack_start
(
self
.
combo
,
True
,
True
,
0
)
self
.
show_all
()
def
on_value_change
(
self
,
combo
):
self
.
set_value
(
combo
.
get_active_id
())
def
on_row_activated
(
self
):
pass
SpinSetting
.
__init__
(
self
,
*
args
,
**
kwargs
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment