diff --git a/data/icons/actions/com.github.gabutakut.gabutdm.uri.svg b/data/icons/actions/com.github.gabutakut.gabutdm.uri.svg index 435fc36..e5477a5 100644 --- a/data/icons/actions/com.github.gabutakut.gabutdm.uri.svg +++ b/data/icons/actions/com.github.gabutakut.gabutdm.uri.svg @@ -24,9 +24,9 @@ inkscape:pagecheckerboard="0" inkscape:deskcolor="#d1d1d1" showgrid="false" - inkscape:zoom="4.9687499" - inkscape:cx="21.031447" - inkscape:cy="12.377359" + inkscape:zoom="7.0268735" + inkscape:cx="25.117856" + inkscape:cy="27.964072" inkscape:window-width="1366" inkscape:window-height="705" inkscape:window-x="0" @@ -120,9 +120,10 @@ y1="40.125" x1="76.25" id="linearGradient4253" - xlink:href="#linearGradient4251" /> + xlink:href="#linearGradient4251" + gradientTransform="matrix(0.54155537,-0.60222633,-0.60222633,-0.54155537,13.599276,83.998113)" /> + xlink:href="#linearGradient4251" + gradientTransform="matrix(0.80991282,0,0,0.80991282,-51.236759,-66.278012)" /> + + + @@ -217,61 +246,63 @@ + id="g368" + transform="matrix(1.4148773,0,0,1.4148773,-18.694342,-0.50016706)"> + style="fill:#d4d4d4;fill-opacity:1;stroke:#000000;stroke-width:0.809913;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:0.427451" + d="m 25.228845,31.298713 c -1.575114,1.751575 -4.253279,1.893636 -6.004854,0.318522 l -2.559462,-2.30161 c -1.751575,-1.575114 -1.893636,-4.253279 -0.318522,-6.004854 l 5.550942,-6.17282 c 1.575114,-1.751575 4.253279,-1.893636 6.004854,-0.318522 l 2.559462,2.30161 c 1.751575,1.575114 1.893636,4.253279 0.318522,6.004854 z m -2.055266,-2.256668 5.144776,-5.72115 c 0.562541,-0.625563 0.511805,-1.58205 -0.113758,-2.144591 l -2.107792,-1.895443 c -0.625562,-0.562541 -1.58205,-0.511805 -2.14459,0.113758 l -5.144776,5.72115 c -0.562541,0.625562 -0.511805,1.58205 0.113758,2.14459 l 2.107792,1.895444 c 0.625562,0.562541 1.58205,0.511805 2.14459,-0.113758 z" + id="rect3650-2" /> + + + + d="m 38.013126,17.180729 c -1.575113,1.751575 -4.253278,1.893636 -6.004854,0.318522 l -2.559461,-2.30161 C 27.697235,13.622527 27.555174,10.944362 29.130288,9.192787 l 5.550943,-6.1728199 c 1.575113,-1.7515752 4.253278,-1.8936363 6.004853,-0.3185225 l 2.559462,2.3016103 c 1.751576,1.5751138 1.893637,4.2532787 0.318523,6.0048541 z M 35.957861,14.924061 41.102637,9.2029111 C 41.665178,8.5773485 41.614441,7.620861 40.988879,7.0583204 L 38.881087,5.1628766 C 38.255524,4.600336 37.299037,4.6510721 36.736496,5.2766347 L 31.59172,10.997785 c -0.562541,0.625562 -0.511805,1.58205 0.113758,2.14459 l 2.107792,1.895444 c 0.625563,0.562541 1.58205,0.511805 2.144591,-0.113758 z" + style="opacity:0.2;fill:url(#linearGradient4253);fill-opacity:1;stroke:none;stroke-width:0.809913;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:0.427451" /> - - - + width="16.198256" + height="3.037173" + x="-0.41472998" + y="-35.298847" + rx="1.8223039" + ry="1.8223039" + transform="matrix(0.66865885,-0.74356933,-0.74356933,-0.66865885,0,0)" /> + style="opacity:0.2;fill:url(#linearGradient4267);fill-opacity:1;stroke:none;stroke-width:0.809913;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:0.427451" + transform="matrix(0.66865885,-0.74356933,-0.74356933,-0.66865885,0,0)" /> diff --git a/meson.build b/meson.build index 62b7387..f26b8fe 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project ('com.github.gabutakut.gabutdm','vala', 'c', version: '2.0.0') +project ('com.github.gabutakut.gabutdm','vala', 'c', version: '2.2.9') i18n = import ('i18n') @@ -19,7 +19,7 @@ dependencies = [ dependency ('cairo'), dependency ('libcurl'), dependency ('libadwaita-1'), - + meson.get_compiler ('vala').find_library ('posix'), ] diff --git a/src/AddUrl.vala b/src/AddUrl.vala index ed21f14..adbd4b0 100644 --- a/src/AddUrl.vala +++ b/src/AddUrl.vala @@ -306,7 +306,7 @@ namespace Gabut { }; overlay.add_overlay (sizelabel); - link_entry = new MediaEntry ("com.github.gabutakut.gabutdm.insertlink", "edit-paste") { + link_entry = new MediaEntry ("com.github.gabutakut.gabutdm.uri", "edit-paste") { width_request = 500, placeholder_text = _("Url or Magnet") }; diff --git a/src/DownloadRow.vala b/src/DownloadRow.vala index 43fdbc4..fcf801b 100644 --- a/src/DownloadRow.vala +++ b/src/DownloadRow.vala @@ -662,12 +662,7 @@ namespace Gabut { } public Gtk.Popover get_menu () { - var downloadmn = new Gtk.FlowBox () { - orientation = Gtk.Orientation.HORIZONTAL, - width_request = 70, - margin_top = 4, - margin_bottom = 4 - }; + var downloadmn = new Gtk.FlowBox (); foreach (var dmmenu in DownloadMenu.get_all ()) { downloadmn.append (new GdmMenu (dmmenu)); } diff --git a/src/GabutWindow.vala b/src/GabutWindow.vala index 993119d..252f7c6 100644 --- a/src/GabutWindow.vala +++ b/src/GabutWindow.vala @@ -42,7 +42,6 @@ namespace Gabut { private DbusmenuItem openmenu; private CanonicalDbusmenu dbusserver; private DbusIndicator dbusindicator; - private Gtk.MenuButton shortbutton; private Gtk.CheckButton showtime; private Gtk.CheckButton showdate; private Gtk.Label download_rate; @@ -157,7 +156,7 @@ namespace Gabut { var urlmenu = new DbusmenuItem (); urlmenu.property_set (MenuItem.LABEL.to_string (), _("Add Url")); - urlmenu.property_set (MenuItem.ICON_NAME.to_string (), "com.github.gabutakut.gabutdm.insertlink"); + urlmenu.property_set (MenuItem.ICON_NAME.to_string (), "com.github.gabutakut.gabutdm.uri"); urlmenu.property_set_bool (MenuItem.VISIBLE.to_string (), true); urlmenu.item_activated.connect (()=> { send_file (""); @@ -344,7 +343,7 @@ namespace Gabut { private Gtk.HeaderBar build_headerbar () { var headerbar = new Gtk.HeaderBar () { hexpand = true, - decoration_layout = ":minimize,close" + decoration_layout = ":close" }; var menu_button = new Gtk.Button.from_icon_name ("com.github.gabutakut.gabutdm.settings") { tooltip_text = _("Settings") @@ -373,30 +372,13 @@ namespace Gabut { }; headerbar.pack_end (host_button); host_button.clicked.connect (qrmenuopen); - var add_button = new Gtk.Button.from_icon_name ("com.github.gabutakut.gabutdm.insertlink") { - tooltip_text = _("add link") - }; - add_button.clicked.connect (()=> { - send_file (""); - }); - headerbar.pack_start (add_button); - var torrentbutton = new Gtk.Button.from_icon_name ("document-open") { - tooltip_text = _("Open .torrent .metalink file") + var add_open = new Gtk.MenuButton () { + child = new Gtk.Image.from_icon_name ("com.github.gabutakut.gabutdm.insertlink"), + direction = Gtk.ArrowType.UP, + popover = get_openmenu (), + tooltip_text = _("Add/Open") }; - headerbar.pack_start (torrentbutton); - torrentbutton.clicked.connect (()=> { - run_open_file.begin (this, OpenFiles.OPENFILES, (obj, res)=> { - try { - GLib.File[] files; - run_open_file.end (res, out files); - foreach (var file in files) { - send_file (file.get_uri ()); - } - } catch (GLib.Error e) { - critical (e.message); - } - }); - }); + headerbar.pack_start (add_open); var resumeall_button = new Gtk.Button.from_icon_name ("com.github.gabutakut.gabutdm.active") { tooltip_text = _("Start All") }; @@ -417,6 +399,43 @@ namespace Gabut { return headerbar; } + public Gtk.Popover get_openmenu () { + var addopen = new Gtk.FlowBox (); + foreach (var openmenu in OpenMenus.get_all ()) { + addopen.append (new OpenMenu (openmenu)); + } + var popovermenu = new Gtk.Popover () { + child = addopen + }; + popovermenu.show.connect (() => { + popovermenu.position = Gtk.PositionType.BOTTOM; + addopen.unselect_all (); + }); + addopen.child_activated.connect ((openmn)=> { + popovermenu.hide (); + var add_open = openmn as OpenMenu; + switch (add_open.openmn) { + case OpenMenus.OPENMN: + run_open_file.begin (this, OpenFiles.OPENFILES, (obj, res)=> { + try { + GLib.File[] files; + run_open_file.end (res, out files); + foreach (var file in files) { + send_file (file.get_uri ()); + } + } catch (GLib.Error e) { + critical (e.message); + } + }); + break; + default: + send_file (""); + break; + } + }); + return popovermenu; + } + private void qrmenuopen () { if (qrcode == null) { qrcode = new QrCode (application) { @@ -495,7 +514,7 @@ namespace Gabut { var property_button = new Gtk.MenuButton () { child = new Gtk.Image.from_icon_name ("com.github.gabutakut.gabutdm.menu"), direction = Gtk.ArrowType.UP, - margin_start = 10, + margin_start = 6, tooltip_text = _("Property") }; properties = new GLib.List (); @@ -550,11 +569,11 @@ namespace Gabut { actionbar.set_center_widget (view_mode); view_mode.notify["selected"].connect (view_status); - shortbutton = new Gtk.MenuButton () { + var shortbutton = new Gtk.MenuButton () { direction = Gtk.ArrowType.UP, child = new Gtk.Image.from_icon_name ("com.github.gabutakut.gabutdm.opt"), popover = get_menu (), - margin_end = 10, + margin_end = 6, tooltip_text = _("Sort by") }; actionbar.set_end_widget (shortbutton); @@ -888,6 +907,7 @@ namespace Gabut { row.activedm.connect (activedm); } }); + list_box.set_sort_func ((Gtk.ListBoxSortFunc) sort_dm); listrow.sort (sort_dm); update_info (); view_status (); @@ -955,6 +975,7 @@ namespace Gabut { } else { aria_pause (row.ariagid); } + list_box.set_sort_func ((Gtk.ListBoxSortFunc) sort_dm); listrow.sort (sort_dm); update_info (); view_status (); diff --git a/src/OpenMenu.vala b/src/OpenMenu.vala new file mode 100755 index 0000000..40cd9d3 --- /dev/null +++ b/src/OpenMenu.vala @@ -0,0 +1,48 @@ +/* +* Copyright (c) {2024} torikulhabib (https://github.com/gabutakut) +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public +* License along with this program; if not, write to the +* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +* Boston, MA 02110-1301 USA +* +* Authored by: torikulhabib +*/ + +namespace Gabut { + public class OpenMenu : Gtk.FlowBoxChild { + public OpenMenus openmn { get; private set; } + + public OpenMenu (OpenMenus openmn) { + this.openmn = openmn; + halign = Gtk.Align.CENTER; + var title = new Gtk.Label (openmn.to_string ()) { + halign = Gtk.Align.START, + wrap_mode = Pango.WrapMode.WORD_CHAR, + attributes = set_attribute (Pango.Weight.BOLD), + margin_top = 6, + margin_bottom = 6, + width_request = 130 + }; + var imgstatus = new Gtk.Image () { + valign = Gtk.Align.CENTER, + gicon = new ThemedIcon (openmn.to_icon ()) + }; + var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); + box.append (imgstatus); + box.append (title); + child = box; + show (); + } + } +} \ No newline at end of file diff --git a/src/Utils.vala b/src/Utils.vala index f87e325..9ddcdfc 100644 --- a/src/Utils.vala +++ b/src/Utils.vala @@ -1384,6 +1384,33 @@ namespace Gabut { } } + public enum OpenMenus { + ADDURL = 0, + OPENMN = 1; + + public string to_string () { + switch (this) { + case OPENMN: + return _("Torrent/Metalink"); + default: + return _("URL/Magnet"); + } + } + + public string to_icon () { + switch (this) { + case OPENMN: + return "document-open"; + default: + return "com.github.gabutakut.gabutdm.uri"; + } + } + + public static OpenMenus [] get_all () { + return { ADDURL, OPENMN}; + } + } + public enum DeAscend { ASCENDING = 0, DESCENDING = 1 diff --git a/src/meson.build b/src/meson.build index eee43ba..ba35277 100644 --- a/src/meson.build +++ b/src/meson.build @@ -41,5 +41,6 @@ sources = files ( 'GdmPaint.vala', 'GdmMenu.vala', 'ProgressPaint.vala', - 'QrcodePaint.vala' -) + 'QrcodePaint.vala', + 'OpenMenu.vala' +) \ No newline at end of file