From 1376d727e9017ce6b3cfd2ca3008d4d5cdd4ff2a Mon Sep 17 00:00:00 2001 From: Vika Date: Fri, 23 Aug 2024 01:56:23 +0300 Subject: Comply with GNOME HIG by ensuring our window can scale to a small size --- src/components/post_editor.rs | 274 +++++++++++++++++++++++------------------- 1 file changed, 148 insertions(+), 126 deletions(-) (limited to 'src/components') diff --git a/src/components/post_editor.rs b/src/components/post_editor.rs index be17251..56d2d94 100644 --- a/src/components/post_editor.rs +++ b/src/components/post_editor.rs @@ -120,149 +120,171 @@ impl Component for PostEditor< #[name = "content_wrapper"] adw::BreakpointBin { set_width_request: 360, - set_height_request: 480, - - #[name = "content"] - gtk::Box { - set_orientation: gtk::Orientation::Vertical, - set_spacing: 5, - set_margin_all: 5, - - #[name = "name_label"] - gtk::Label { - set_markup: "Name", - set_margin_vertical: 10, - set_margin_horizontal: 10, - set_halign: gtk::Align::Start, - set_valign: gtk::Align::Start, - }, - #[name = "name_field"] - gtk::Entry { - set_hexpand: true, - set_buffer: &model.name_buffer, - #[track = "model.changed(Self::sending())"] - set_sensitive: !model.sending, - }, + set_height_request: 200, - #[name = "summary_label"] - gtk::Label { - set_markup: "Summary", - set_margin_vertical: 10, - set_margin_horizontal: 10, - set_halign: gtk::Align::Start, - set_valign: gtk::Align::Start, - }, - #[name = "summary_field"] + gtk::ScrolledWindow { + #[name = "content"] gtk::Box { - set_orientation: gtk::Orientation::Horizontal, - add_css_class: "linked", - + set_orientation: gtk::Orientation::Vertical, + set_spacing: 5, + set_margin_all: 5, + + #[name = "name_label"] + gtk::Label { + set_markup: "Name", + set_margin_vertical: 10, + set_margin_horizontal: 10, + set_halign: gtk::Align::Start, + set_valign: gtk::Align::Start, + }, + #[name = "name_field"] gtk::Entry { set_hexpand: true, - set_buffer: &model.summary_buffer, - #[track = "model.busy_changed()"] - set_sensitive: !model.busy(), + set_buffer: &model.name_buffer, + #[track = "model.changed(Self::sending())"] + set_sensitive: !model.sending, }, - model.smart_summary.widget(), - }, + #[name = "summary_label"] + gtk::Label { + set_markup: "Summary", + set_margin_vertical: 10, + set_margin_horizontal: 10, + set_halign: gtk::Align::Start, + set_valign: gtk::Align::Start, + }, + #[name = "summary_field"] + gtk::Box { + set_orientation: gtk::Orientation::Horizontal, + add_css_class: "linked", - #[name = "tag_label"] - gtk::Label { - set_markup: "Tags", - set_margin_vertical: 10, - set_margin_horizontal: 10, - set_halign: gtk::Align::Start, - set_valign: gtk::Align::Start, - }, - #[name = "tag_holder"] - // TODO: tag component (because of complex logic) - gtk::Box { - add_css_class: "frame", - set_hexpand: true, - set_orientation: gtk::Orientation::Horizontal, - set_spacing: 5, - set_height_request: 36, - }, + gtk::Entry { + set_hexpand: true, + set_buffer: &model.summary_buffer, + #[track = "model.busy_changed()"] + set_sensitive: !model.busy(), + }, + model.smart_summary.widget(), + }, - #[name = "content_label"] - gtk::Label { - set_markup: "Content", - set_halign: gtk::Align::Start, - set_valign: gtk::Align::Start, - set_margin_vertical: 10, - set_margin_horizontal: 10, - }, + #[name = "tag_label"] + gtk::Label { + set_markup: "Tags", + set_margin_vertical: 10, + set_margin_horizontal: 10, + set_halign: gtk::Align::Start, + set_valign: gtk::Align::Start, + }, + #[name = "tag_holder"] + gtk::Box { + set_hexpand: true, + set_orientation: gtk::Orientation::Vertical, + set_spacing: 5, + set_height_request: 36, + + gtk::Box { + add_css_class: "linked", + set_orientation: gtk::Orientation::Horizontal, + + #[name = "pending_tag_entry"] + gtk::Entry { + set_hexpand: true, + set_width_request: 200, + #[track = "model.changed(Self::sending())"] + set_sensitive: !model.sending, + }, + gtk::Button { + set_icon_name: "plus-symbolic", + add_css_class: "suggested-action", + } + }, - #[name = "content_textarea"] - gtk::ScrolledWindow { - set_vexpand: true, - gtk::TextView { - set_buffer: Some(&model.content_buffer), - set_hexpand: true, - #[iterate] - add_css_class: &["frame", "view"], - set_monospace: true, - set_wrap_mode: gtk::WrapMode::Word, - set_vscroll_policy: gtk::ScrollablePolicy::Natural, + #[name = "content_label"] + gtk::Label { + set_markup: "Content", + set_halign: gtk::Align::Start, + set_valign: gtk::Align::Start, + set_margin_vertical: 10, + set_margin_horizontal: 10, + }, - set_left_margin: 8, - set_right_margin: 8, - set_top_margin: 8, - set_bottom_margin: 8, + #[name = "content_textarea_wrapper"] + gtk::ScrolledWindow { + set_vexpand: true, + set_height_request: 200, + #[name = "content_textarea"] + gtk::TextView { + set_buffer: Some(&model.content_buffer), + set_hexpand: true, + #[iterate] + add_css_class: &["frame", "view"], + + set_monospace: true, + set_wrap_mode: gtk::WrapMode::Word, + set_vscroll_policy: gtk::ScrollablePolicy::Natural, + + set_left_margin: 8, + set_right_margin: 8, + set_top_margin: 8, + set_bottom_margin: 8, + + #[track = "model.changed(Self::sending())"] + set_sensitive: !model.sending + } + }, - #[track = "model.changed(Self::sending())"] - set_sensitive: !model.sending - } - }, + #[name = "misc_prop_wrapper"] + gtk::Box { + set_hexpand: true, - #[name = "misc_prop_wrapper"] - gtk::Box { - set_hexpand: true, + gtk::FlowBox { + set_hexpand: false, + set_orientation: gtk::Orientation::Horizontal, + set_homogeneous: false, + set_column_spacing: 0, + set_min_children_per_line: 2, + set_max_children_per_line: 6, + set_selection_mode: gtk::SelectionMode::None, - gtk::FlowBox { - set_hexpand: false, - set_orientation: gtk::Orientation::Horizontal, - set_homogeneous: false, - set_column_spacing: 0, - set_min_children_per_line: 2, - set_max_children_per_line: 6, - set_selection_mode: gtk::SelectionMode::None, - - append = >k::Box { - set_spacing: 5, - - #[name = "visibility_label"] - gtk::Label { - set_markup: "Visibility", + append = >k::FlowBoxChild { set_halign: gtk::Align::Start, - set_valign: gtk::Align::Start, - set_margin_vertical: 10, - set_margin_horizontal: 10, - }, - #[name = "visibility_selector"] - gtk::DropDown { - set_model: Some(&visibility_model), - set_hexpand: false, - - #[track = "model.changed(Self::sending())"] - set_sensitive: !model.sending, - connect_selected_item_notify[sender] => move |w| { - if let Some(obj) = w.selected_item() { - let v = obj.downcast::() - .unwrap() - .value(); - let v = glib::EnumClass::new::() - .to_value(v) - .unwrap() - .get() - .unwrap(); - sender.input(Self::Input::VisibilitySelected(v)); - } + gtk::Box { + set_spacing: 5, + + #[name = "visibility_label"] + gtk::Label { + set_markup: "Visibility", + set_halign: gtk::Align::Start, + set_valign: gtk::Align::Start, + set_margin_vertical: 10, + set_margin_horizontal: 10, + }, + #[name = "visibility_selector"] + gtk::DropDown { + set_model: Some(&visibility_model), + set_hexpand: false, + + #[track = "model.changed(Self::sending())"] + set_sensitive: !model.sending, + + connect_selected_item_notify[sender] => move |w| { + if let Some(obj) = w.selected_item() { + let v = obj.downcast::() + .unwrap() + .value(); + let v = glib::EnumClass::new::() + .to_value(v) + .unwrap() + .get() + .unwrap(); + sender.input(Self::Input::VisibilitySelected(v)); + } + }, + }, }, }, }, @@ -355,7 +377,7 @@ impl Component for PostEditor< Row::TwoColumn(&widgets.name_label, widgets.name_field.upcast_ref::()), Row::TwoColumn(&widgets.summary_label, widgets.summary_field.upcast_ref::()), Row::TwoColumn(&widgets.tag_label, widgets.tag_holder.upcast_ref::()), - Row::TwoColumn(&widgets.content_label, widgets.content_textarea.upcast_ref::()), + Row::TwoColumn(&widgets.content_label, widgets.content_textarea_wrapper.upcast_ref::()), Row::Span(widgets.misc_prop_wrapper.upcast_ref::()), ].into_iter().enumerate() { match content { -- cgit 1.4.1