Commit 30c74503 authored by Thibault Saunier's avatar Thibault Saunier

render: Use a TextWidget for preset name widget

Instead of having a Gtk.Box that contains the preset widgets, use a
Gtk.Grid, allowig higher control when packing the TextWidget in code.

This will be useful so that the preset name can be properly verified
to be valid (when we will use GstEncodingTarget for the serialization
format).

Also allow using a standard GtkComboBox for the TextWidget as this is
what we need for that case.
Reviewed-by: Alexandru Băluț's avatarAlex Băluț <alexandru.balut@gmail.com>
Differential Revision: https://phabricator.freedesktop.org/D1590
parent b248730d
......@@ -199,46 +199,10 @@
</packing>
</child>
<child>
<object class="GtkBox" id="preset_box">
<object class="GtkGrid" id="preset_table">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Preset:</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="presets_combo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_entry">True</property>
<child internal-child="entry">
<object class="GtkEntry" id="combobox-entry">
<property name="can_focus">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="preset_menubutton">
<property name="visible">True</property>
......@@ -254,11 +218,29 @@
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="xpad">10</property>
<property name="label" translatable="yes">Preset:</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="left_attach">0</property>
......
......@@ -42,6 +42,7 @@ from pitivi.utils.ui import frame_rates
from pitivi.utils.ui import get_combo_value
from pitivi.utils.ui import set_combo_value
from pitivi.utils.widgets import GstElementSettingsDialog
from pitivi.utils.widgets import TextWidget
class Encoders(Loggable):
......@@ -560,9 +561,14 @@ class RenderDialog(Loggable):
self.filebutton = builder.get_object("filebutton")
self.fileentry = builder.get_object("fileentry")
self.resolution_label = builder.get_object("resolution_label")
self.presets_combo = builder.get_object("presets_combo")
self.preset_menubutton = builder.get_object("preset_menubutton")
text_widget = TextWidget(matches=r'^[a-z][a-z-0-9-]+$', combobox=True)
self.presets_combo = text_widget.combo
preset_table = builder.get_object("preset_table")
preset_table.attach(text_widget, 1, 0, 1, 1)
text_widget.show()
self.video_output_checkbutton.props.active = self.project.video_profile.is_enabled()
self.audio_output_checkbutton.props.active = self.project.audio_profile.is_enabled()
......
......@@ -46,10 +46,11 @@ from pitivi.utils.ui import unpack_color
ZOOM_SLIDER_PADDING = SPACING * 4 / 5
class DynamicWidget(object):
class DynamicWidget(Loggable):
"""Abstract widget providing a way to get, set and observe properties."""
def __init__(self, default):
super().__init__()
self.default = default
def connectValueChanged(self, callback, *args):
......@@ -107,7 +108,7 @@ class TextWidget(Gtk.Box, DynamicWidget):
"activate": (GObject.SignalFlags.RUN_LAST, None, (),)
}
def __init__(self, matches=None, choices=None, default=None):
def __init__(self, matches=None, choices=None, default=None, combobox=False):
if not default:
# In the case of text widgets, a blank default is an empty string
default = ""
......@@ -126,6 +127,11 @@ class TextWidget(Gtk.Box, DynamicWidget):
self.pack_start(self.combo, expand=False, fill=False, padding=0)
for choice in choices:
self.combo.append_text(choice)
elif combobox:
self.combo = Gtk.ComboBox.new_with_entry()
self.text = self.combo.get_child()
self.combo.show()
self.pack_start(self.combo, expand=False, fill=False, padding=0)
else:
self.text = Gtk.Entry()
self.text.show()
......
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