Commit 72c41046 authored by Christopher Davis's avatar Christopher Davis Committed by Daniel Garcia Moreno

Redesigned new room creation (fixes #98)

* Changes minimum window width
* Uses StackSwitcher-like setup instead of dropdown
parent 3d3a8734
Pipeline #9853 failed with stage
in 6 minutes and 58 seconds
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.2 -->
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkListStore" id="new_room_combo">
<columns>
<!-- column-name name -->
......@@ -21,17 +20,46 @@
</row>
</data>
</object>
<object class="GtkDialog" id="new_room_dialog">
<property name="can_focus">False</property>
<property name="modal">True</property>
<property name="window_position">center</property>
<property name="default_width">440</property>
<property name="default_height">240</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property>
<property name="deletable">False</property>
<property name="gravity">center</property>
<property name="transient_for">main_window</property>
<property name="attached_to">main_window</property>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Create new room</property>
<child>
<object class="GtkButton" id="cancel_new_room">
<property name="label" translatable="yes">Cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
</child>
<child>
<object class="GtkButton" id="new_room_button">
<property name="label" translatable="yes">Create</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<style>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can_focus">False</property>
......@@ -51,82 +79,133 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkGrid">
<object class="GtkBox" id="new_room_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">30</property>
<property name="margin_right">30</property>
<property name="margin_top">30</property>
<property name="margin_bottom">30</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<property name="orientation">vertical</property>
<property name="spacing">18</property>
<child>
<object class="GtkLabel" id="new_room_name_label">
<object class="GtkBox" id="room_box_top">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Name</property>
<accessibility>
<relation type="label-for" target="new_room_name"/>
</accessibility>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="new_room_preset_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Privacy</property>
<accessibility>
<relation type="label-for" target="new_room_preset"/>
</accessibility>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="new_room_name">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<accessibility>
<relation type="labelled-by" target="new_room_name_label"/>
</accessibility>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="new_room_name_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Room name</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
<accessibility>
<relation type="label-for" target="new_room_name"/>
</accessibility>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="new_room_name">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="new_room_preset">
<object class="GtkBox" id="room_box_bottom">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="model">new_room_combo</property>
<property name="active">0</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="new_room_preset_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Visibility</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="GtkCellRendererText"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
<object class="GtkButtonBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="layout_style">expand</property>
<child>
<object class="GtkRadioButton" id="private_visibility_button">
<property name="label" translatable="yes">Private</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">False</property>
<property name="group">public_visibility_button</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="public_visibility_button">
<property name="label" translatable="yes">Public</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">False</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<accessibility>
<relation type="labelled-by" target="new_room_preset_label"/>
</accessibility>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
......@@ -138,35 +217,5 @@
</child>
</object>
</child>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Create new Room</property>
<child>
<object class="GtkButton" id="cancel_new_room">
<property name="label" translatable="yes">Cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
</child>
<child>
<object class="GtkButton" id="new_room_button">
<property name="label" translatable="yes">Create</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<style>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="pack_type">end</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
......@@ -1767,26 +1767,16 @@ impl AppOp {
let name = self.ui.builder
.get_object::<gtk::Entry>("new_room_name")
.expect("Can't find new_room_name in ui file.");
let preset = self.ui.builder
.get_object::<gtk::ComboBox>("new_room_preset")
.expect("Can't find new_room_preset in ui file.");
let private = self.ui.builder
.get_object::<gtk::ToggleButton>("private_visibility_button")
.expect("Can't find private_visibility_button in ui file.");
let n = name.get_text().unwrap_or(String::from(""));
let p = match preset.get_active_iter() {
None => backend::RoomType::Private,
Some(iter) => {
match preset.get_model() {
None => backend::RoomType::Private,
Some(model) => {
match model.get_value(&iter, 1).get().unwrap() {
"private_chat" => backend::RoomType::Private,
"public_chat" => backend::RoomType::Public,
_ => backend::RoomType::Private,
}
}
}
}
// Since the switcher
let p = match private.get_active() {
true => backend::RoomType::Private,
false => backend::RoomType::Public,
};
let internal_id: String = thread_rng().gen_ascii_chars().take(10).collect();
......@@ -2577,22 +2567,29 @@ impl App {
let entry = self.ui.builder
.get_object::<gtk::Entry>("new_room_name")
.expect("Can't find new_room_name in ui file.");
let private = self.ui.builder
.get_object::<gtk::ToggleButton>("private_visibility_button")
.expect("Can't find private_visibility_button in ui file.");
cancel.connect_clicked(clone!(entry, dialog => move |_| {
private.clone().set_active(true);
cancel.connect_clicked(clone!(entry, dialog, private => move |_| {
dialog.hide();
entry.set_text("");
private.set_active(true);
}));
dialog.connect_delete_event(clone!(entry, dialog => move |_, _| {
dialog.connect_delete_event(clone!(entry, dialog, private => move |_, _| {
dialog.hide();
entry.set_text("");
private.set_active(true);
glib::signal::Inhibit(true)
}));
let op = self.op.clone();
confirm.connect_clicked(clone!(entry, dialog => move |_| {
confirm.connect_clicked(clone!(entry, dialog, private => move |_| {
dialog.hide();
op.lock().unwrap().create_new_room();
entry.set_text("");
private.set_active(true);
}));
let op = self.op.clone();
......@@ -2600,6 +2597,7 @@ impl App {
dialog.hide();
op.lock().unwrap().create_new_room();
entry.set_text("");
private.set_active(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