20
20
*/
21
21
22
22
namespace Gabut {
23
- public class GabutWindow : Gtk . Window {
23
+ public class GabutWindow : Hdy . ApplicationWindow {
24
24
public signal void send_file (string url );
25
25
public signal void stop_server ();
26
26
public signal void restart_server ();
27
27
public signal string get_host (bool reboot );
28
28
private Gtk . ListBox list_box;
29
- private Gtk . Revealer search_rev ;
29
+ private Gtk . Stack headerstack ;
30
30
private Gtk . Revealer property_rev;
31
31
private Preferences preferences = null ;
32
32
private QrCode qrcode;
@@ -41,7 +41,6 @@ namespace Gabut {
41
41
}
42
42
43
43
construct {
44
- get_style_context (). add_class (" rounded" );
45
44
nodown_alert = new AlertView (
46
45
_(" No File Download" ),
47
46
_(" Insert Link, add Torrent, add Metalink, Magnet URIs." ),
@@ -56,38 +55,38 @@ namespace Gabut {
56
55
list_box. set_placeholder (nodown_alert);
57
56
58
57
var scrolled = new Gtk .ScrolledWindow (null , null ) {
58
+ height_request = 350 ,
59
+ width_request = 650 ,
59
60
expand = true
60
61
};
62
+ scrolled. get_style_context (). add_class (" frame" );
61
63
scrolled. add (list_box);
62
64
63
- var overlay = new Gtk .Overlay ();
64
- overlay. add (scrolled);
65
-
66
- var frame = new Gtk .Frame (null ) {
67
- width_request = 350 ,
68
- height_request = 350 ,
69
- expand = true
70
- };
71
- frame. add (overlay);
72
- var image_label = new Gtk .Grid () {
73
- margin_bottom = 5
65
+ headerstack = new Gtk .Stack () {
66
+ transition_type = Gtk . StackTransitionType . SLIDE_DOWN ,
67
+ transition_duration = 500 ,
68
+ hhomogeneous = false
74
69
};
70
+ headerstack. add_named (mode_headerbar (), " mode" );
71
+ headerstack. add_named (saarch_headerbar (), " search" );
72
+ headerstack. visible_child_name = " mode" ;
73
+ headerstack. show_all ();
74
+
75
75
var frame_header = new Gtk .Grid () {
76
76
orientation = Gtk . Orientation . VERTICAL ,
77
- valign = Gtk . Align . CENTER ,
78
- width_request = 650
77
+ valign = Gtk . Align . START
79
78
};
80
- frame_header. get_style_context (). add_class (Gtk . STYLE_CLASS_HEADER );
81
- frame_header. get_style_context (). add_class (" default-decoration" );
82
- search_rev = new Gtk .Revealer () {
83
- transition_type = Gtk . RevealerTransitionType . SLIDE_DOWN
84
- };
85
- search_rev. add (saarch_headerbar ());
86
79
frame_header. add (build_headerbar ());
87
- frame_header. add (mode_headerbar ());
88
- frame_header. add (search_rev);
89
- set_titlebar (frame_header);
90
- add (frame);
80
+ frame_header. add (headerstack);
81
+
82
+ var mainwindow = new Gtk .Grid () {
83
+ orientation = Gtk . Orientation . VERTICAL ,
84
+ expand = true
85
+ };
86
+ mainwindow. get_style_context (). add_class (" rounded" );
87
+ mainwindow. add (frame_header);
88
+ mainwindow. add (scrolled);
89
+ add (mainwindow);
91
90
list_box. remove. connect ((wid)= > {
92
91
view_status ();
93
92
});
@@ -103,21 +102,21 @@ namespace Gabut {
103
102
return hide_on_delete ();
104
103
} else {
105
104
stop_server ();
106
- check_table ();
107
105
return false ;
108
106
}
109
107
});
110
108
}
111
109
112
- private Gtk .HeaderBar build_headerbar () {
113
- var headerbar = new Gtk .HeaderBar () {
114
- hexpand = true ,
110
+ private Hdy .HeaderBar build_headerbar () {
111
+ var headerbar = new Hdy .HeaderBar () {
115
112
title = _ ("Gabut Download Manager "),
116
113
has_subtitle = false,
117
114
show_close_button = true,
115
+ interpolate_size = false,
118
116
decoration_layout = "close:maximize"
119
117
};
120
118
headerbar.get_style_context ().add_class (Gtk .STYLE_CLASS_FLAT );
119
+ move_widget (headerbar );
121
120
var menu_button = new Gtk .Button .from_icon_name (" open-menu" , Gtk . IconSize . BUTTON ) {
122
121
tooltip_text = _ ("Open Settings ")
123
122
};
@@ -143,9 +142,14 @@ namespace Gabut {
143
142
};
144
143
headerbar.pack_end (search_button );
145
144
search_button.clicked.connect (()=> {
146
- search_rev. reveal_child = ! search_rev. reveal_child;
145
+ ((Gtk . Image ) search_button. image). icon_name = headerstack. visible_child_name == " mode" ? " com.github.gabutakut.gabutdm" : " system-search" ;
146
+ headerstack. visible_child_name = headerstack. visible_child_name == " mode" ? headerstack. visible_child_name = " search" : headerstack. visible_child_name = " mode" ;
147
+ var row = (DownloadRow ) list_box. get_selected_row ();
148
+ if (row != null ) {
149
+ list_box. unselect_row (row);
150
+ }
147
151
});
148
- search_rev .notify["child-revealed "].connect (()=> {
152
+ headerstack .notify["visible-child "].connect (()=> {
149
153
view_status ();
150
154
search_entry. text = " " ;
151
155
});
@@ -191,7 +195,7 @@ namespace Gabut {
191
195
}
192
196
});
193
197
property_rev = new Gtk .Revealer () {
194
- transition_type = Gtk . RevealerTransitionType . SLIDE_RIGHT
198
+ transition_type = Gtk . RevealerTransitionType . CROSSFADE
195
199
};
196
200
property_rev.add (property_button );
197
201
headerbar.pack_end (property_rev );
@@ -301,7 +305,6 @@ namespace Gabut {
301
305
var headerbar = new Gtk .Box (Gtk . Orientation . HORIZONTAL , 0 ) {
302
306
hexpand = true
303
307
};
304
- headerbar. get_style_context (). add_class (Gtk . STYLE_CLASS_FLAT );
305
308
headerbar. get_style_context (). add_class (" default-decoration" );
306
309
view_mode = new ModeButton () {
307
310
hexpand = false ,
@@ -314,18 +317,17 @@ namespace Gabut {
314
317
view_mode. append_text (_(" Waiting" ));
315
318
view_mode. append_text (_(" Error" ));
316
319
view_mode. selected = 0 ;
317
- view_mode. get_style_context (). add_class (Gtk . STYLE_CLASS_FLAT );
318
320
headerbar. set_center_widget (view_mode);
319
321
view_mode. notify[" selected" ]. connect (view_status);
320
322
return headerbar;
321
323
}
322
324
323
325
private Gtk .Box saarch_headerbar () {
324
326
var box_s = new Gtk .Box (Gtk . Orientation . HORIZONTAL , 0 );
325
- box_s. get_style_context (). add_class (Gtk . STYLE_CLASS_FLAT );
326
327
box_s. get_style_context (). add_class (" default-decoration" );
327
328
search_entry = new Gtk .SearchEntry () {
328
- placeholder_text = _ ("Search Download File ")
329
+ placeholder_text = _ ("Search Download File "),
330
+ margin = 2
329
331
};
330
332
search_entry.search_changed.connect (view_status );
331
333
box_s.set_center_widget (search_entry );
@@ -464,7 +466,7 @@ namespace Gabut {
464
466
}
465
467
466
468
public void view_status () {
467
- if (search_rev . child_revealed ) {
469
+ if (headerstack . visible_child_name == " search " ) {
468
470
list_box. set_filter_func ((item) = > {
469
471
return ((DownloadRow ) item). filename. casefold (). contains (search_entry. text. casefold ());
470
472
});
0 commit comments