Commit c5dc046f authored by Canek Peláez's avatar Canek Peláez
Browse files

Port to Adwaita.

parent 749a14e5
Loading
Loading
Loading
Loading

data/application-window.ui

deleted100644 → 0
+0 −92
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<interface>
  <requires lib="gtk" version="4.0"/>
  <object class="GListStore" id="nodes_model">
    <property name="item-type">GtkJsonApplicationNodeRow</property>
  </object>
  <menu id="gtkjson_main_menu">
    <section>
      <item>
        <attribute name="label">Open JSON...</attribute>
        <attribute name="action">app.open</attribute>
      </item>
      <item>
        <attribute name="label">About GtkJson...</attribute>
        <attribute name="action">app.about</attribute>
      </item>
    </section>
    <section>
      <item>
        <attribute name="label">Quit</attribute>
        <attribute name="action">app.quit</attribute>
      </item>
    </section>
  </menu>
  <template class="GtkJsonApplicationApplicationWindow" parent="GtkApplicationWindow">
    <property name="width-request">800</property>
    <property name="height-request">600</property>
    <signal name="close-request" handler="on_close_request" swapped="no"/>
    <child type="titlebar">
      <object class="GtkHeaderBar" id="header">
        <property name="title-widget">
          <object class="GtkBox">
            <property name="valign">center</property>
            <property name="spacing">1</property>
            <property name="orientation">vertical</property>
            <child>
              <object class="GtkLabel">
                <property name="label" translatable="yes">GtkJson</property>
                <property name="single-line-mode">true</property>
                <style>
                  <class name="title" />
                </style>
              </object>
            </child>
            <child>
              <object class="GtkLabel" id="subtitle">
                <property name="label" translatable="yes">GtkJson</property>
                <property name="single-line-mode">true</property>
                <style>
                  <class name="subtitle" />
                </style>
              </object>
            </child>
          </object>
        </property>
        <child type="end">
          <object class="GtkMenuButton" id="menu_button">
            <property name="primary">true</property>
            <property name="tooltip-text" translatable="yes">GtkJson menu</property>
            <property name="menu-model">gtkjson_main_menu</property>
            <child>
              <object class="GtkImage" id="menu_image">
                <property name="icon-name">open-menu-symbolic</property>
                <property name="icon-size">normal</property>
              </object>
            </child>
          </object>
        </child>
      </object>
    </child>
    <child>
      <object class="GtkScrolledWindow" id="json_scroll">
        <property name="has-frame">true</property>
        <child>
          <object class="GtkListView" id="nodes_list">
            <property name="model">
              <object class="GtkSingleSelection" id="nodes_selection" />
            </property>
            <property name="factory">
              <object class="GtkBuilderListItemFactory">
                <property name="resource">/mx/unam/GtkJson/node-row.ui</property>
              </object>
            </property>
          </object>
        </child>
        <style>
          <class name="content" />
        </style>
      </object>
    </child>
  </template>
</interface>

data/gtk/main-menu.blp

0 → 100644
+20 −0
Original line number Diff line number Diff line
using Gtk 4.0;

menu main_menu {
  section {
    item {
      label: "Open JSON...";
      action: "app.open";
    }
    item {
      label: "About GtkJson...";
      action: "app.about";
    }
  }
  section {
    item {
      label: "Quit";
      action: "app.quit";
    }
  }
}

data/gtk/node-item.blp

0 → 100644
+38 −0
Original line number Diff line number Diff line
using Gtk 4.0;

template ListItem {
  child: TreeExpander expander {
    list-row: bind template.item;

    child: Box {
      spacing: 6;
      orientation: horizontal;
      has-tooltip: true;

      query-tooltip => $gtk_json_node_row_query_tooltip();

      Label {
        xalign: 0.0;
        halign: start;
        label: bind (expander.item as <$GtkJsonNodeRow>).node-type;
        css-classes: bind (expander.item as <$GtkJsonNodeRow>).css-type;
      }

      Label {
        xalign: 0.0;
        halign: start;
        label: bind (expander.item as <$GtkJsonNodeRow>).node-key;
        css-classes: bind (expander.item as <$GtkJsonNodeRow>).css-key;
      }

      Label {
        xalign: 0.0;
        halign: start;
        label: bind (expander.item as <$GtkJsonNodeRow>).node-value;
        css-classes: bind (expander.item as <$GtkJsonNodeRow>).css-value;
      }
    };
  };
}

data/gtk/window.blp

0 → 100644
+95 −0
Original line number Diff line number Diff line
/*
 * This file is part of GtkJson.
 *
 * Copyright © 2016-2024 Canek Peláez Valdés
 *
 * 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 <https://www.gnu.org/licenses/>.
 */

using Gtk 4.0;
using Gio 2.0;
using Adw 1;

FilterListModel filtered_nodes_model {

  model: Gio.ListStore nodes_model {
    item-type: typeof<$GtkJsonNodeRow>;
  };

  filter: $GtkJsonNodeRowFilter nodes_filter {
    query: "";
  };
}

template $GtkJsonWindow : Adw.ApplicationWindow {
  visible: false;

  width-request: 800;
  height-request: 600;

  content: Adw.ToolbarView {
    top-bar-style: raised;

    [top]
    Adw.HeaderBar {
      title-widget: Box {
        orientation: vertical;
        spacing: 0;

        Label {
          label: "GtkJson";
          styles ["title"]
        }

        Label {
          label: bind template.subtitle;
          styles ["subtitle"]
        }
      };

      [end]
      MenuButton {
        tooltip-text: _("GtkJson menu");
        icon-name: "open-menu-symbolic";
        primary: true;
        menu-model: bind template.menu_model;
      }
    }

    content: Adw.Clamp {
      maximum-size: 1920;
      tightening-threshold: 800;
      width-request: 600;
      height-request: 600;
      margin-end: 24;
      margin-start: 24;
      margin-top: 24;
      margin-bottom: 24;

      child: ScrolledWindow {
        has-frame: true;
        vexpand: true;
        hexpand: true;

        ListView nodes_list {
          model: SingleSelection nodes_selection {
          };
          factory: BuilderListItemFactory {
            resource: "/mx/unam/GtkJson/gtk/node-item.ui";
          };
        }
      };
    };
  };
}
+3 −2
Original line number Diff line number Diff line
@@ -2,7 +2,8 @@
<gresources>
  <gresource prefix="/mx/unam/GtkJson">
    <file>style.css</file>
    <file preprocess="xml-stripblanks">application-window.ui</file>
    <file preprocess="xml-stripblanks">node-row.ui</file>
    <file preprocess="xml-stripblanks">gtk/main-menu.ui</file>
    <file preprocess="xml-stripblanks">gtk/node-item.ui</file>
    <file preprocess="xml-stripblanks">gtk/window.ui</file>
  </gresource>
</gresources>
Loading