Skip to content

Commit

Permalink
#3070 use Gtk.Scale for speed and quality, hide audio codecs
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Apr 14, 2021
1 parent daa7516 commit b84212d
Showing 1 changed file with 52 additions and 18 deletions.
70 changes: 52 additions & 18 deletions xpra/gtk_common/start_gui.py
Expand Up @@ -78,7 +78,7 @@ def help_clicked(*args):
btn = imagebutton("" if icon else label, icon, label, help_clicked, 12, False)
return btn

def attach_label(table, label, tooltip_text, link=None):
def attach_label(table, label, tooltip_text=None, link=None):
lbl = Gtk.Label(label)
if tooltip_text:
lbl.set_tooltip_text(tooltip_text)
Expand Down Expand Up @@ -721,6 +721,28 @@ def combo(self, table, label, option_name, options, link=None):
table.inc()
return c

def scale(self, table, label, option_name, minv=0, maxv=100, marks=None):
attach_label(table, label)
fn = option_name.replace("-", "_")
value = getattr(self.options, fn)
#c = Gtk.Scale.new_with_range(Gtk.Orientation.HORIZONTAL, minv, maxv, 10)
c = Gtk.Scale.new(Gtk.Orientation.HORIZONTAL)
c.set_range(minv, maxv)
c.set_draw_value(True)
c.set_digits(0)
c.set_hexpand(True)
c.set_value(value or 0)
c.set_valign(Gtk.Align.START)
if marks:
for v,label in marks.items():
c.add_mark(v, Gtk.PositionType.BOTTOM, label)
table.attach(c, 1)
setattr(self, "%s_widget" % fn, c)
setattr(self, "%s_widget_type" % fn, "scale")
self.widgets.append(option_name)
table.inc()
return c

def set_value_from_widgets(self):
for option_name in self.widgets:
self.set_value_from_widget(option_name)
Expand All @@ -735,6 +757,9 @@ def set_value_from_widget(self, option_name):
values = self.valuesfromradio(option_name)
elif widget_type=="combo":
values = self.valuesfromcombo(option_name)
elif widget_type=="scale":
widget = getattr(self, "%s_widget" % fn)
values = (int(widget.get_value()), )
else:
log.warn("unknown widget type '%s'", widget_type)
if len(values)!=1 or values[0]!=UNSET:
Expand Down Expand Up @@ -879,17 +904,24 @@ def populate_form(self):
tb = self.table()
qoptions = MIN_QUALITY_OPTIONS.copy()
qoptions.pop(0, None)
self.combo(tb, "Minimum Quality", "min-quality", qoptions)
soptions = MIN_SPEED_OPTIONS.copy()
soptions.pop(0, None)
self.combo(tb, "Minimum Speed", "min-speed", soptions)
self.scale(tb, "Minimum Quality", "min-quality", marks={
0 : "Very Low",
30 : "Low",
50 : "Medium",
75 : "High",
100 : "Lossless",
})
self.scale(tb, "Minimum Speed", "min-speed", marks={
0 : "Low Bandwidth",
100 : "Low Latency",
})
self.sep(tb)
self.combo(tb, "Auto-refresh", "auto-refresh-delay", {
0 : "disabled",
0.1 : "fast",
0.15 : "normal",
0.5 : "slow",
})
self.sep(tb)
from xpra.client.mixins.encodings import get_core_encodings
encodings = ["auto", "rgb"] + get_core_encodings()
encodings.remove("rgb24")
Expand Down Expand Up @@ -951,23 +983,25 @@ def populate_form(self):
"off" : FALSE_OPTIONS,
"disabled" : ("disabled", ),
})
tb.attach(Gtk.Label("Speaker Codec"))
self.speaker_codec_widget = Gtk.ComboBoxText()
for v in ("mp3", "wav"):
self.speaker_codec_widget.append_text(v)
tb.attach(self.speaker_codec_widget, 1)
tb.inc()
self.sep(tb)
#tb.attach(Gtk.Label("Speaker Codec"))
#self.speaker_codec_widget = Gtk.ComboBoxText()
#for v in ("mp3", "wav"):
# self.speaker_codec_widget.append_text(v)
#tb.attach(self.speaker_codec_widget, 1)
#tb.inc()
self.radio_cb(tb, "Microphone", "microphone", None, None, {
"on" : TRUE_OPTIONS,
"off" : FALSE_OPTIONS,
"disabled" : ("disabled", ),
})
tb.attach(Gtk.Label("Microphone Codec"))
self.microphone_codec_widget = Gtk.ComboBoxText()
for v in ("mp3", "wav"):
self.microphone_codec_widget.append_text(v)
tb.attach(self.microphone_codec_widget, 1)
tb.inc()
self.sep(tb)
#tb.attach(Gtk.Label("Microphone Codec"))
#self.microphone_codec_widget = Gtk.ComboBoxText()
#for v in ("mp3", "wav"):
# self.microphone_codec_widget.append_text(v)
#tb.attach(self.microphone_codec_widget, 1)
#tb.inc()
self.bool_cb(tb, "AV Sync", "av-sync")
self.vbox.show_all()

Expand Down

0 comments on commit b84212d

Please sign in to comment.