File: bookmarks-controller.vala

package info (click to toggle)
dconf-editor 49.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,904 kB
  • sloc: xml: 446; sh: 21; makefile: 4
file content (72 lines) | stat: -rw-r--r-- 2,704 bytes parent folder | download | duplicates (3)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
  This file is part of Dconf Editor

  Dconf Editor 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 3 of the License, or
  (at your option) any later version.

  Dconf Editor 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 Dconf Editor.  If not, see <https://www.gnu.org/licenses/>.
*/

using Gtk;

[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/bookmarks-controller.ui")]
private class BookmarksController : Grid
{
    [GtkChild] private unowned Image big_rows_icon;
    [GtkChild] private unowned Image small_rows_icon;

    [GtkChild] private unowned Button rows_size_button;
    [CCode (notify = false)] public bool show_rows_size_button { private get; construct; default = false; }

    [GtkChild] private unowned Button trash_bookmark_button;
    [GtkChild] private unowned Button move_top_button;
    [GtkChild] private unowned Button move_up_button;
    [GtkChild] private unowned Button move_down_button;
    [GtkChild] private unowned Button move_bottom_button;
    [CCode (notify = false)] public string controller_action_prefix
    {
        construct
        {
            // TODO sanitize "value"
            trash_bookmark_button.set_detailed_action_name (value + ".trash-bookmark");
            move_top_button.set_detailed_action_name (value + ".move-top");
            move_up_button.set_detailed_action_name (value + ".move-up");
            move_down_button.set_detailed_action_name (value + ".move-down");
            move_bottom_button.set_detailed_action_name (value + ".move-bottom");
        }
    }

    construct
    {
        if (show_rows_size_button)      // TODO construct instead of hiding
            rows_size_button.show ();
        else
            rows_size_button.hide ();
    }

    internal BookmarksController (string _controller_action_prefix, bool _show_rows_size_button)
    {
        Object (controller_action_prefix: _controller_action_prefix, show_rows_size_button: _show_rows_size_button);
    }

    internal void update_rows_size_button_icon (bool small_bookmarks_rows)
    {
        if (small_bookmarks_rows)
            rows_size_button.set_image (big_rows_icon);
        else
            rows_size_button.set_image (small_rows_icon);
    }

    internal bool get_small_rows_state ()
    {
        return rows_size_button.get_image () == small_rows_icon;
    }
}