/* Css.vala
 *
 * Copyright 2022 Paulo Queiroz <pvaqueiroz@gmail.com>
 *
 * 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 3 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, see <http://www.gnu.org/licenses/>.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

namespace Terminal {
  public void set_css_class (
    Gtk.Widget widget,
    string classname,
    bool enabled = true
  ) {
    if (enabled) {
      widget.add_css_class (classname);
    }
    else {
      widget.remove_css_class (classname);
    }
  }

  public bool is_dark_style_active () {
    return Adw.StyleManager.get_default ().dark;
  }

  public Gtk.CssProvider? get_css_provider_for_data(string data) {
    var provider = new Gtk.CssProvider();

    provider.load_from_string (data);

    return provider;
  }
}
