@@ -20,30 +20,22 @@ mod imp {
2020 impl ObjectSubclass for AdvancedMessageDialog {
2121 const NAME : & ' static str = "AdvancedMessageDialog" ;
2222 type Type = super :: AdvancedMessageDialog ;
23- type ParentType = adw:: Window ;
23+ type ParentType = adw:: Dialog ;
2424 }
2525
2626 impl ObjectImpl for AdvancedMessageDialog { }
2727 impl WidgetImpl for AdvancedMessageDialog { }
28- impl WindowImpl for AdvancedMessageDialog { }
29- impl AdwWindowImpl for AdvancedMessageDialog { }
28+ impl AdwDialogImpl for AdvancedMessageDialog { }
3029}
3130
3231glib:: wrapper! {
3332 pub struct AdvancedMessageDialog ( ObjectSubclass <imp:: AdvancedMessageDialog >)
34- @extends gtk:: Widget , gtk :: Window , adw:: Window ;
33+ @extends gtk:: Widget , adw:: Dialog ;
3534}
3635
3736impl AdvancedMessageDialog {
38- pub fn new (
39- parent : & impl IsA < gtk:: Window > ,
40- subscription : Subscription ,
41- message : String ,
42- ) -> Self {
37+ pub fn new ( subscription : Subscription , message : String ) -> Self {
4338 let this: Self = glib:: Object :: new ( ) ;
44- this. set_transient_for ( Some ( parent) ) ;
45- this. set_modal ( true ) ;
46- this. set_default_height ( 400 ) ;
4739 this. imp ( ) . subscription . set ( subscription) . unwrap ( ) ;
4840 this. build_ui (
4941 this. imp ( ) . subscription . get ( ) . unwrap ( ) . topic ( ) . clone ( ) ,
@@ -52,14 +44,17 @@ impl AdvancedMessageDialog {
5244 this
5345 }
5446 fn build_ui ( & self , topic : String , message : String ) {
47+ self . set_title ( "Advanced Message" ) ;
48+ self . set_content_height ( 480 ) ;
49+ self . set_content_width ( 480 ) ;
5550 let this = self . clone ( ) ;
5651 relm4_macros:: view! {
5752 content = & adw:: ToolbarView {
5853 add_top_bar = & adw:: HeaderBar { } ,
5954 #[ wrap( Some ) ]
6055 set_content: toast_overlay = & adw:: ToastOverlay {
6156 #[ wrap( Some ) ]
62- set_child = & adw :: Clamp {
57+ set_child = & gtk :: ScrolledWindow {
6358 #[ wrap( Some ) ]
6459 set_child = & gtk:: Box {
6560 set_margin_top: 8 ,
@@ -82,22 +77,19 @@ impl AdvancedMessageDialog {
8277 set_xalign: 0.0 ,
8378 set_halign: gtk:: Align :: Start ,
8479 } ,
85- append = & gtk:: ScrolledWindow {
86- #[ wrap( Some ) ]
87- set_child: text_view = & gsv:: View {
88- add_css_class: "code" ,
89- set_tab_width: 4 ,
90- set_indent_width: 2 ,
91- set_auto_indent: true ,
92- set_top_margin: 4 ,
93- set_bottom_margin: 4 ,
94- set_left_margin: 4 ,
95- set_right_margin: 4 ,
96- set_hexpand: true ,
97- set_vexpand: true ,
98- set_monospace: true ,
99- set_background_pattern: gsv:: BackgroundPatternType :: Grid
100- } ,
80+ append: text_view = & gsv:: View {
81+ add_css_class: "code" ,
82+ set_tab_width: 4 ,
83+ set_indent_width: 2 ,
84+ set_auto_indent: true ,
85+ set_top_margin: 4 ,
86+ set_bottom_margin: 4 ,
87+ set_left_margin: 4 ,
88+ set_right_margin: 4 ,
89+ set_hexpand: true ,
90+ set_vexpand: true ,
91+ set_monospace: true ,
92+ set_background_pattern: gsv:: BackgroundPatternType :: Grid
10193 } ,
10294 append = & gtk:: Label {
10395 add_css_class: "heading" ,
@@ -166,9 +158,9 @@ impl AdvancedMessageDialog {
166158 add_css_class: "circular" ,
167159 add_css_class: "small" ,
168160 set_label: "?" ,
169- connect_clicked[ this ] => move |_| {
161+ connect_clicked => move |_| {
170162 gtk:: UriLauncher :: new( "https://docs.ntfy.sh/publish/#publish-as-json" ) . launch(
171- Some ( & this ) ,
163+ None :: < & gtk :: Window > ,
172164 gio:: Cancellable :: NONE ,
173165 |_| { }
174166 ) ;
@@ -221,6 +213,6 @@ impl AdvancedMessageDialog {
221213 } ;
222214 let scheme = gsv:: StyleSchemeManager :: default ( ) . scheme ( scheme_name) ;
223215 buffer. set_style_scheme ( scheme. as_ref ( ) ) ;
224- this. set_content ( Some ( & content) ) ;
216+ this. set_child ( Some ( & content) ) ;
225217 }
226218}
0 commit comments