focus on your browsing
browser web-browser

implement functionality for the close tab button

add functionality for the copy link and website settings button

woof.monster 201e52b4 8bb078fe

verified
+58 -11
+4
OuchBrowser/Styles.css
··· 45 45 .top-bar.raised { 46 46 background: var(--window-bg-color); 47 47 } 48 + 49 + .website-settings > contents { 50 + border-radius: 20px; 51 + }
+2
OuchBrowser/UI.cs
··· 28 28 [Connect] public readonly Button? go_forward; 29 29 [Connect] public readonly Button? refresh; 30 30 [Connect] public readonly WindowControls? left_controls; 31 + [Connect] public readonly Button? copy_link; 32 + [Connect] public readonly MenuButton? website_settings; 31 33 32 34 public Window(Adw.Application app) : base() 33 35 {
+24 -11
OuchBrowser/UI/Builder/Window.blp
··· 105 105 orientation: horizontal; 106 106 margin-start: 10; 107 107 margin-end: 10; 108 - // Button copy_link_button { 109 - // icon-name: "chain-link-loose-symbolic"; 110 - // tooltip-text: _("Copy link"); 111 - // } 108 + 112 109 Button url_button { 113 110 hexpand: true; 114 111 sensitive: false; ··· 126 123 } 127 124 } 128 125 129 - Button { 126 + Button copy_link { 130 127 icon-name: "chain-link-loose-symbolic"; 131 128 tooltip-text: _("Copy Link"); 129 + action-name: "win.copy-link"; 132 130 } 133 131 134 - Button { 132 + MenuButton website_settings { 135 133 icon-name: "sliders-horizontal-symbolic"; 136 134 tooltip-text: _("Website Settings"); 135 + 136 + popover: Popover { 137 + width-request: 300; 138 + 139 + styles [ 140 + "website-settings", 141 + ] 142 + 143 + Adw.StatusPage { 144 + icon-name: "sliders-horizontal-symbolic"; 145 + title: _("No Website Settings Available"); 146 + 147 + styles [ 148 + "compact", 149 + ] 150 + } 151 + }; 137 152 } 138 153 139 - // Button { 140 - // icon-name: "sliders-horizontal-symbolic"; 141 - // tooltip-text: _("Website settings"); 142 - // } 143 154 styles [ 144 155 "linked", 145 156 ] ··· 249 260 margin-start: 2; 250 261 visible: bind template.item as <Adw.TabPage>.selected; 251 262 tooltip-text: _("Close Tab"); 263 + action-name: "win.tab-close"; 252 264 253 265 styles [ 254 266 "flat", ··· 297 309 name: "space-2"; 298 310 } 299 311 }; */ 300 - end-widget: MenuButton { 312 + end-widget: Adw.SplitButton { 301 313 icon-name: "tab-new-symbolic"; 302 314 tooltip-text: _("New…"); 303 315 margin-end: 10; 304 316 menu-model: new_menu; 317 + action-name: "win.palette-new"; 305 318 306 319 styles [ 307 320 "flat",
+2
OuchBrowser/View.cs
··· 123 123 window.refresh!.SetSensitive(true); 124 124 window.refresh!.SetTooltipText(window.gettext.GetString("Stop loading")); 125 125 window.url_button!.SetSensitive(true); 126 + window.copy_link!.SetSensitive(true); 127 + window.website_settings!.SetSensitive(true); 126 128 window.sidebar_toggle!.SetSensitive(true); 127 129 window.refresh!.SetIconName("cross-large-symbolic"); 128 130 page.SetLoading(true);
+26
OuchBrowser/Window.cs
··· 27 27 window.go_back!.SetSensitive(false); 28 28 window.go_forward!.SetSensitive(false); 29 29 window.refresh!.SetSensitive(false); 30 + window.copy_link!.SetSensitive(false); 31 + window.url_button!.SetSensitive(false); 32 + window.website_settings!.SetSensitive(false); 30 33 31 34 // TODO: maybe make this a little bit less "hacky?" 32 35 window.content_sidebar_toggle!.OnClicked += (_, _) => ··· 479 482 window.go_back!.SetSensitive(false); 480 483 window.go_forward!.SetSensitive(false); 481 484 window.url_button!.SetSensitive(false); 485 + window.copy_link!.SetSensitive(false); 486 + window.website_settings!.SetSensitive(false); 482 487 window.sidebar_toggle!.SetSensitive(false); 483 488 window.sidebar_toggle!.SetActive(true); 484 489 window.hostname!.SetLabel(""); ··· 503 508 504 509 TabPage page = window.view!.GetSelectedPage()!; 505 510 WebView webview = (WebView)page.Child!; 511 + 512 + webview.GoForward(); 513 + }); 514 + 515 + actions.AddAction("copy-link", ["<Ctrl><Shift>c"], (_, _) => 516 + { 517 + if (window.view!.GetNPages() == 0) return; 518 + 519 + TabPage page = window.view!.GetSelectedPage()!; 520 + WebView webview = (WebView)page.Child!; 521 + Toast toast = Toast.New(""); 522 + 523 + string uri = webview.GetUri(); 524 + Gdk.Display display = Gdk.Display.GetDefault()!; 525 + Gdk.Clipboard clipboard = display!.GetClipboard(); 526 + clipboard.SetText(uri); 527 + 528 + toast.SetTitle(window.gettext.GetString("Link copied")); 529 + toast.SetTimeout(1); 530 + window.toast_overlay!.DismissAll(); 531 + window.toast_overlay!.AddToast(toast); 506 532 507 533 webview.GoForward(); 508 534 });