Commit 521007fa authored by Daniel Brötzmann's avatar Daniel Brötzmann Committed by Philipp Hörist

Rework Preferences

parent 637ae4b8
Pipeline #6323 passed with stages
in 4 minutes and 27 seconds
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.2 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkBox" id="video_preview_box">
<property name="height_request">250</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="video_source_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<object class="GtkBox" id="video_preview_placeholder">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">camera-web-symbolic</property>
<property name="icon_size">6</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Live Preview</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</interface>
......@@ -79,6 +79,15 @@ popover#EmoticonPopover { padding: 5px; background-color: @theme_unfocused_base_
.settings-box > row { padding: 10px 20px 10px 10px; }
.settings-box > row:not(.activatable) label { color: @insensitive_fg_color; }
window.settings-dialog row {
border-bottom: 0px;
}
window.settings-dialog list {
background: transparent;
margin: 12px;
}
/* GenericSetting */
#SubDescription { color: @insensitive_fg_color; font-size: small;}
#GenericSettingBox { margin-left: 30px; }
......@@ -91,9 +100,8 @@ popover#EmoticonPopover { padding: 5px; background-color: @theme_unfocused_base_
.PopoverButtonListbox > list > row.activatable:active { box-shadow: none; background-color: @theme_selected_bg_color; }
/* Settings ListBox */
list.settings {
border: @borders 1px solid;
border: @borders 1px solid;
}
list.settings > row:not(:last-child) {
border-bottom: @theme_unfocused_bg_color 1px solid;
......@@ -103,6 +111,27 @@ list.settings > row > box {
margin: 6px 18px;
}
/* Settings Window */
list.settings-menu row {
border-bottom: 1px solid;
border-color: @theme_unfocused_bg_color;
padding: 14px;
min-width: 170px;
}
list.settings-menu row label {
padding-left: 12px;
}
.settings-stack viewport > box {
margin-left: 30px;
margin-right: 30px;
margin-bottom: 10px;
margin-top: 25px;
}
.settings-border {
border: 1px solid;
border-color: @borders;
}
/* InfoBar */
infobar.info > revealer > box {
color: #3A87AD;
......@@ -124,10 +153,6 @@ infobar.error > revealer > box {
/*SendFileDialog*/
#SendFileDialog grid list > row { padding: 10px 20px 10px 10px; }
/* Preferences Window */
.PreferencesWindow { background-color: @theme_base_color; }
.PreferencesStack { background-color: @theme_bg_color; }
/* Accounts Window */
.accounts-menu { border-right: 1px solid; border-color: @borders;}
.accounts-settings-border {border: 1px solid; border-color: @borders;}
......@@ -333,12 +358,24 @@ button.flat.link { padding: 0; border: 0; }
}
popover.combo list { min-width: 200px; margin: 12px;}
popover.combo list {
min-width: 200px;
margin: 12px;
}
popover.combo { padding: 0px; }
popover.combo list { border-style: none; background-color: transparent; }
popover.combo list > row { padding: 0px 12px 0px 12px; min-height: 50px; }
popover.combo list {
border-style: none;
background-color: transparent;
}
popover.combo list > row {
padding: 0px 12px 0px 12px;
min-height: 40px;
}
popover.combo list > row:not(:last-child) { border-bottom: 1px solid alpha(#cdc7c2, 0.5); }
popover.combo scrollbar.vertical { padding-top: 2px; padding-bottom: 2px; }
popover.combo scrollbar.vertical {
padding-top: 2px;
padding-bottom: 2px;
}
messagedialog.confirmation-dialog > box { margin-top: 18px; }
......@@ -58,6 +58,9 @@ class SettingKind(IntEnum):
COMBO = 12
COLOR = 13
POPOVER = 14
AUTO_AWAY = 15
AUTO_EXTENDED_AWAY = 16
USE_STUN_SERVER = 17
@unique
......
This diff is collapsed.
......@@ -44,6 +44,7 @@ class SettingsDialog(Gtk.ApplicationWindow):
self.set_resizable(False)
self.set_default_size(250, -1)
self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
self.get_style_context().add_class('settings-dialog')
self.account = account
if flags == Gtk.DialogFlags.MODAL:
self.set_modal(True)
......@@ -93,6 +94,9 @@ class SettingsBox(Gtk.ListBox):
SettingKind.CHANGEPASSWORD: ChangePasswordSetting,
SettingKind.COMBO: ComboSetting,
SettingKind.POPOVER: PopoverSetting,
SettingKind.AUTO_AWAY: CutstomAutoAwaySetting,
SettingKind.AUTO_EXTENDED_AWAY: CutstomAutoExtendedAwaySetting,
SettingKind.USE_STUN_SERVER: CutstomStunServerSetting
}
if extend is not None:
......@@ -721,3 +725,30 @@ class ChangePasswordSetting(DialogSetting):
activatable = (con.state.is_available and
con.get_module('Register').supported)
self.set_activatable(activatable)
class CutstomAutoAwaySetting(DialogSetting):
def __init__(self, *args, **kwargs):
DialogSetting.__init__(self, *args, **kwargs)
def get_setting_value(self):
value = app.settings.get('autoaway')
return Q_('?switch:On') if value else Q_('?switch:Off')
class CutstomAutoExtendedAwaySetting(DialogSetting):
def __init__(self, *args, **kwargs):
DialogSetting.__init__(self, *args, **kwargs)
def get_setting_value(self):
value = app.settings.get('autoxa')
return Q_('?switch:On') if value else Q_('?switch:Off')
class CutstomStunServerSetting(DialogSetting):
def __init__(self, *args, **kwargs):
DialogSetting.__init__(self, *args, **kwargs)
def get_setting_value(self):
value = app.settings.get('use_stun_server')
return Q_('?switch:On') if value else Q_('?switch:Off')
# This file is part of Gajim.
#
# Gajim is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; version 3 only.
#
# Gajim is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
from gi.repository import Gtk
class SideBarSwitcher(Gtk.ListBox):
def __init__(self):
Gtk.ListBox.__init__(self)
self._stack = None
self.get_style_context().add_class('settings-menu')
self.connect('row-activated', self._on_row_activated)
def set_stack(self, stack):
self._stack = stack
for page in self._stack.get_children():
attributes = ['name', 'title', 'icon-name']
properties = self._stack.child_get(page, *attributes)
self.add(Row(*properties))
self._select_first_row()
def _on_row_activated(self, _listbox, row):
self._stack.set_visible_child_name(row.name)
def _select_first_row(self):
self.select_row(self.get_row_at_index(0))
class Row(Gtk.ListBoxRow):
def __init__(self, name, title, icon_name):
Gtk.ListBoxRow.__init__(self)
self.name = name
box = Gtk.Box()
if icon_name:
image = Gtk.Image.new_from_icon_name(icon_name, Gtk.IconSize.MENU)
image.get_style_context().add_class('dim-label')
box.add(image)
label = Gtk.Label(label=title)
label.set_xalign(0)
box.add(label)
self.add(box)
......@@ -200,7 +200,6 @@ class Themes(Gtk.ApplicationWindow):
self._ui.option_listbox.set_placeholder(self._ui.placeholder)
self._ui.connect_signals(self)
self.connect('destroy', self._on_destroy)
self.connect_after('key-press-event', self._on_key_press)
self.show_all()
......@@ -305,6 +304,8 @@ class Themes(Gtk.ApplicationWindow):
if not app.css_config.add_new_theme(name):
return
self._update_preferences_window()
self._ui.remove_theme_button.set_sensitive(True)
iter_ = self._ui.theme_store.append([name])
self._select_theme_row(iter_)
......@@ -320,7 +321,7 @@ class Themes(Gtk.ApplicationWindow):
app.interface.roster.repaint_themed_widgets()
app.interface.roster.change_roster_style(None)
# Update Preferences theme combobox
def _update_preferences_window(self):
window = get_app_window('Preferences')
if window is not None:
window.update_theme_list()
......@@ -344,6 +345,7 @@ class Themes(Gtk.ApplicationWindow):
self._apply_theme('default')
app.css_config.remove_theme(theme)
self._update_preferences_window()
store.remove(iter_)
first = store.get_iter_first()
......@@ -365,12 +367,6 @@ class Themes(Gtk.ApplicationWindow):
callback=_remove_theme)],
transient_for=self).show()
@staticmethod
def _on_destroy(*args):
window = get_app_window('Preferences')
if window is not None:
window.update_theme_list()
class Option(Gtk.ListBoxRow):
def __init__(self, option, value):
......
# This file is part of Gajim.
#
# Gajim is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; version 3 only.
#
# Gajim is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
import logging
from gi.repository import GLib
from gajim.common import app
from gajim.common.i18n import _
from gajim.gtk import gstreamer
from gajim.gtk.util import get_builder
try:
from gi.repository import Gst # pylint: disable=ungrouped-imports
except Exception:
pass
log = logging.getLogger('gajim.gtk.preview')
class VideoPreview:
def __init__(self):
self._ui = get_builder('video_preview.ui')
self._active = False
self._av_pipeline = None
self._av_src = None
self._av_sink = None
self._av_widget = None
@property
def widget(self):
return self._ui.video_preview_box
@property
def is_active(self):
return self._active
def toggle_preview(self, value):
self._active = value
if value:
return self._enable_preview()
return self._disable_preview()
def _enable_preview(self):
src_name = app.settings.get('video_input_device')
try:
self._av_src = Gst.parse_bin_from_description(src_name, True)
except GLib.Error as error:
log.error(error)
log.error('Failed to parse "%s" as Gstreamer element', src_name)
self._set_error_text()
return
sink, widget, name = gstreamer.create_gtk_widget()
if sink is None:
log.error('Failed to obtain a working Gstreamer GTK+ sink, '
'video support will be disabled')
self._set_error_text()
return
self._set_sink_text(name)
if self._av_pipeline is None:
self._av_pipeline = Gst.Pipeline.new('preferences-pipeline')
else:
self._av_pipeline.set_state(Gst.State.NULL)
self._av_pipeline.add(sink)
self._av_sink = sink
if self._av_widget is not None:
self._ui.video_preview_box.remove(self._av_widget)
self._ui.video_preview_placeholder.set_visible(False)
self._ui.video_preview_box.pack_end(widget, True, True, 0)
self._av_widget = widget
self._av_pipeline.add(self._av_src)
self._av_src.link(self._av_sink)
self._av_pipeline.set_state(Gst.State.PLAYING)
def _disable_preview(self):
if self._av_pipeline is not None:
self._av_pipeline.set_state(Gst.State.NULL)
if self._av_src is not None:
self._av_pipeline.remove(self._av_src)
self._av_src = None
if self._av_sink is not None:
self._av_pipeline.remove(self._av_sink)
self._av_sink = None
if self._av_widget is not None:
self._ui.video_preview_box.remove(self._av_widget)
self._ui.video_preview_placeholder.set_visible(True)
self._av_widget = None
self._av_pipeline = None
def _set_sink_text(self, sink_name):
text = ''
if sink_name == 'gtkglsink':
text = _('<span color="green" font-weight="bold">'
'OpenGL</span> accelerated')
elif sink_name == 'gtksink':
text = _('<span color="yellow" font-weight="bold">'
'Not accelerated</span>')
self._ui.video_source_label.set_markup(text)
def _set_error_text(self):
self._ui.video_source_label.set_text(
_('Something went wrong. Video feature disabled.'))
def refresh(self):
self.toggle_preview(False)
self.toggle_preview(True)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment