11/*
2- * Copyright 2021 elementary, Inc. (https://elementary.io)
3- *
4- * This program is free software; you can redistribute it and/or
5- * modify it under the terms of the GNU General Public
6- * License as published by the Free Software Foundation; either
7- * version 3 of the License, or (at your option) any later version.
8- *
9- * This program is distributed in the hope that it will be useful,
10- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12- * General Public License for more details.
13- *
14- * You should have received a copy of the GNU General Public
15- * License along with this program; if not, write to the
16- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17- * Boston, MA 02110-1301 USA
2+ * SPDX-License-Identifier: GPL-3.0-or-later
3+ * SPDX-FileCopyrightText: 2021-2025 elementary, Inc. (https://elementary.io)
184 *
195 * Authored by: Torikulhabib <torik.habib@gamail.com>
20- *
216 */
227
23- public class BtReceiver : Granite .Dialog {
8+ public class ReceiverDialog : Granite .Dialog {
249 public Bluetooth . Obex . Transfer transfer;
10+
2511 private Gtk . ProgressBar progressbar;
2612 private Gtk . Label device_label;
2713 private Gtk . Label directory_label;
@@ -35,9 +21,10 @@ public class BtReceiver : Granite.Dialog {
3521 private int start_time = 0 ;
3622 private uint64 total_size = 0 ;
3723
38- public BtReceiver (Gtk .Application application ) {
39- Object (application: application,
40- resizable : false
24+ public ReceiverDialog (Gtk .Application application ) {
25+ Object (
26+ application: application,
27+ resizable : false
4128 );
4229 }
4330
@@ -46,17 +33,19 @@ public class BtReceiver : Granite.Dialog {
4633 notification. set_priority (NotificationPriority . NORMAL );
4734
4835 var icon_image = new Gtk .Image .from_icon_name (" io.elementary.bluetooth" , Gtk . IconSize . DIALOG ) {
49- valign = Gtk . Align . END ,
50- halign = Gtk . Align . END
36+ valign = END ,
37+ halign = END
5138 };
5239
5340 device_image = new Gtk .Image () {
54- halign = Gtk . Align . END ,
55- valign = Gtk . Align . END
41+ halign = END ,
42+ valign = END ,
43+ pixel_size = 24
5644 };
5745
58- var overlay = new Gtk .Overlay ();
59- overlay. add (icon_image);
46+ var overlay = new Gtk .Overlay () {
47+ child = icon_image
48+ };
6049 overlay. add_overlay (device_image);
6150
6251 device_label = new Gtk .Label (null ) {
@@ -73,45 +62,53 @@ public class BtReceiver : Granite.Dialog {
7362 wrap = true ,
7463 xalign = 0
7564 };
65+
7666 filename_label = new Gtk .Label (null ) {
7767 max_width_chars = 45 ,
7868 use_markup = true ,
7969 wrap = true ,
8070 xalign = 0
8171 };
72+
8273 rate_label = new Gtk .Label (_(" <b>Transfer rate:</b>" )) {
8374 max_width_chars = 45 ,
8475 use_markup = true ,
8576 wrap = true ,
8677 xalign = 0
8778 };
79+
8880 progressbar = new Gtk .ProgressBar () {
8981 hexpand = true
9082 };
83+
9184 progress_label = new Gtk .Label (null ) {
9285 max_width_chars = 45 ,
9386 hexpand = false ,
9487 wrap = true ,
9588 xalign = 0
9689 };
90+
9791 var message_grid = new Gtk .Grid () {
9892 column_spacing = 0 ,
9993 width_request = 450 ,
10094 margin_end = 15 ,
10195 margin_start = 10
10296 };
10397 message_grid. attach (overlay, 0 , 0 , 1 , 3 );
104- message_grid. attach (device_label, 1 , 0 , 1 , 1 );
105- message_grid. attach (directory_label, 1 , 1 , 1 , 1 );
106- message_grid. attach (filename_label, 1 , 2 , 1 , 1 );
107- message_grid. attach (rate_label, 1 , 3 , 1 , 1 );
108- message_grid. attach (progressbar, 1 , 4 , 1 , 1 );
109- message_grid. attach (progress_label, 1 , 5 , 1 , 1 );
98+ message_grid. attach (device_label, 1 , 0 );
99+ message_grid. attach (directory_label, 1 , 1 );
100+ message_grid. attach (filename_label, 1 , 2 );
101+ message_grid. attach (rate_label, 1 , 3 );
102+ message_grid. attach (progressbar, 1 , 4 );
103+ message_grid. attach (progress_label, 1 , 5 );
104+
110105 get_content_area (). add (message_grid);
111106
112107 add_button (_(" Close" ), Gtk . ResponseType . CLOSE );
108+
113109 var suggested_button = add_button (_(" Reject" ), Gtk . ResponseType . ACCEPT );
114110 suggested_button. get_style_context (). add_class (Gtk . STYLE_CLASS_DESTRUCTIVE_ACTION );
111+
115112 response. connect ((response_id) = > {
116113 if (response_id == Gtk . ResponseType . ACCEPT ) {
117114 try {
@@ -124,6 +121,7 @@ public class BtReceiver : Granite.Dialog {
124121 hide_on_delete ();
125122 }
126123 });
124+
127125 delete_event. connect (() = > {
128126 if (transfer. status == " active" ) {
129127 return hide_on_delete ();
@@ -136,7 +134,8 @@ public class BtReceiver : Granite.Dialog {
136134 public void set_transfer (string devicename , string deviceicon , string objectpath ) {
137135 device_label. set_markup (GLib . Markup . printf_escaped (_(" <b>From</b>: %s " ), devicename));
138136 directory_label. label = GLib . Markup . printf_escaped (_(" <b>To</b>: %s " ), GLib . Environment . get_user_special_dir (UserDirectory . DOWNLOAD ));
139- device_image. set_from_gicon (new ThemedIcon (deviceicon == null ? " bluetooth" : deviceicon), Gtk . IconSize . LARGE_TOOLBAR );
137+ device_image. gicon = new ThemedIcon (deviceicon == null ? " bluetooth" : deviceicon);
138+
140139 start_time = (int ) get_real_time ();
141140 try {
142141 transfer = Bus . get_proxy_sync (BusType . SESSION , " org.bluez.obex" , objectpath);
@@ -150,6 +149,7 @@ public class BtReceiver : Granite.Dialog {
150149 GLib . warning (e. message);
151150 }
152151 }
152+
153153 private void tranfer_progress () {
154154 try {
155155 switch (transfer. status) {
@@ -178,6 +178,7 @@ public class BtReceiver : Granite.Dialog {
178178 critical (e. message);
179179 }
180180 }
181+
181182 private void move_to_folder (string file ) throws GLib .Error {
182183 var src = File . new_for_path (file);
183184 var dest = change_name (Path . build_filename (GLib . Environment . get_user_special_dir (UserDirectory . DOWNLOAD ), src. get_basename ()));
0 commit comments