File: BackButton.vala

package info (click to toggle)
granite-7 7.7.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,876 kB
  • sloc: xml: 86; makefile: 9
file content (39 lines) | stat: -rw-r--r-- 1,008 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * Copyright 2025 elementary, Inc. (https://elementary.io)
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

/**
 * BackButton is meant to be used in headers to navigate in
 * {@link Adw.NavigationView}.
 *
 * By default `action_name` is set to `navigation.pop`
 */
[Version (since = "7.7.0")]
public class Granite.BackButton : Gtk.Button {
    /**
     * Text of the label inside of #this
     */
    public new string label { get; set; }

    public BackButton (string label) {
        Object (label: label);
    }

    construct {
        var image = new Gtk.Image.from_icon_name ("go-previous-symbolic");

        var label_widget = new Gtk.Label ("");

        var box = new Gtk.Box (HORIZONTAL, 0);
        box.append (image);
        box.append (label_widget);

        action_name = "navigation.pop";
        child = box;
        tooltip_markup = Granite.markup_accel_tooltip ({"<alt>Left"});

        add_css_class ("text-button");
        bind_property ("label", label_widget, "label");
    }
}