Commit 0ada3935 authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui

window: use hdyApplicationWindow

parent ec52bbaa
Pipeline #195820 failed with stage
in 1 minute and 29 seconds
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="modal">True</property> <property name="modal">True</property>
<property name="type_hint">dialog</property> <property name="type_hint">dialog</property>
<property name="program_name" translatable="yes">@name-prefix@Icon Library</property> <property name="program_name" translatable="yes">Icon Library</property>
<property name="version">@version@</property> <property name="version">@version@</property>
<property name="website">https://gitlab.gnome.org/World/design/icon-library</property> <property name="website">https://gitlab.gnome.org/World/design/icon-library</property>
<property name="authors">Bilal Elmoussaoui</property> <property name="authors">Bilal Elmoussaoui</property>
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<requires lib="libhandy" version="0.0"/> <requires lib="libhandy" version="0.0"/>
<object class="GtkStack" id="icons_view"> <object class="GtkStack" id="icons_view">
<property name="visible">True</property> <property name="visible">True</property>
<property name="expand">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="transition_type">crossfade</property> <property name="transition_type">crossfade</property>
<child> <child>
...@@ -12,32 +13,50 @@ ...@@ -12,32 +13,50 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<child> <child>
<object class="GtkViewport"> <object class="HdyClamp">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="shadow_type">none</property> <property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="maximum_size">900</property>
<property name="tightening_threshold">900</property>
<child> <child>
<object class="HdyClamp"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin_left">12</property> <property name="orientation">vertical</property>
<property name="margin_right">12</property>
<property name="maximum_size">900</property>
<property name="tightening_threshold">900</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox" id="shipped_icons_container">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin_bottom">24</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkBox" id="shipped_icons_container"> <placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="system_help_container">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin_bottom">24</property> <property name="halign">start</property>
<property name="orientation">vertical</property> <property name="valign">center</property>
<child> <property name="margin_top">12</property>
<placeholder/> <property name="label" translatable="yes">Pre-Installed System Icons</property>
</child> <style>
<class name="title-1"/>
</style>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -46,50 +65,20 @@ ...@@ -46,50 +65,20 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkBox" id="system_help_container"> <object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="orientation">vertical</property> <property name="halign">start</property>
<child> <property name="margin_top">12</property>
<object class="GtkLabel"> <property name="margin_bottom">12</property>
<property name="visible">True</property> <property name="label" translatable="yes">These icons come with the operating system, which means you have no control over them and they could change at any time. Only use them if you're sure you are using them in the correct context (e.g. three lines for a primary menu).</property>
<property name="can_focus">False</property> <property name="justify">fill</property>
<property name="halign">start</property> <property name="wrap">True</property>
<property name="valign">center</property> <property name="ellipsize">end</property>
<property name="margin_top">12</property> <property name="lines">2</property>
<property name="label" translatable="yes">Pre-Installed System Icons</property> <style>
<style> <class name="body"/>
<class name="title-1"/> </style>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="label" translatable="yes">These icons come with the operating system, which means you have no control over them and they could change at any time. Only use them if you're sure you are using them in the correct context (e.g. three lines for a primary menu).</property>
<property name="justify">fill</property>
<property name="wrap">True</property>
<property name="ellipsize">end</property>
<property name="lines">2</property>
<style>
<class name="body"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -97,26 +86,31 @@ ...@@ -97,26 +86,31 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<object class="GtkBox" id="system_icons_container">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">24</property>
<property name="orientation">vertical</property>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
<child>
<object class="GtkBox" id="system_icons_container">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">24</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child> </child>
</object> </object>
</child> </child>
...@@ -170,7 +164,6 @@ ...@@ -170,7 +164,6 @@
</object> </object>
<packing> <packing>
<property name="name">no-results</property> <property name="name">no-results</property>
<property name="position">1</property>
</packing> </packing>
</child> </child>
</object> </object>
......
...@@ -46,74 +46,80 @@ ...@@ -46,74 +46,80 @@
</packing> </packing>
</child> </child>
</object> </object>
<object class="GtkApplicationWindow" id="window"> <object class="HdyApplicationWindow" id="window">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="default_width">650</property> <property name="default_width">650</property>
<property name="default_height">500</property> <property name="default_height">500</property>
<property name="icon_name">@app-id@</property> <property name="icon_name">@app-id@</property>
<property name="title" translatable="yes">@name-prefix@Icon Library</property> <property name="title" translatable="yes">Icon Library</property>
<child type="titlebar"> <child>
<object class="HdyHeaderBar" id="headerbar"> <object class="GtkBox" id="container">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="orientation">vertical</property>
<property name="show_close_button">True</property> <child>
<property name="centering_policy">HDY_CENTERING_POLICY_STRICT</property> <object class="HdyHeaderBar" id="headerbar">
<child type="title">
<object class="HdyClamp">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="tightening_threshold">400</property> <property name="show_close_button">True</property>
<property name="hexpand">True</property> <property name="centering_policy">HDY_CENTERING_POLICY_STRICT</property>
<child> <child type="title">
<object class="GtkSearchEntry" id="search_entry"> <object class="HdyClamp">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="primary_icon_name">edit-find-symbolic</property> <property name="tightening_threshold">400</property>
<property name="primary_icon_activatable">False</property> <property name="hexpand">True</property>
<property name="primary_icon_sensitive">False</property> <child>
<property name="placeholder_text" translatable="yes">Search for icons by name, category or tag</property> <object class="GtkSearchEntry" id="search_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_name">edit-find-symbolic</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
<property name="placeholder_text" translatable="yes">Search for icons by name, category or tag</property>
</object>
</child>
</object> </object>
</child> </child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="action_name">app.dark-mode</property>
<property name="tooltip_text" translatable="yes">Toggle Dark Mode</property>
<child> <child>
<object class="GtkImage" id="dark_mode_image"> <object class="GtkButton">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="icon_name">dark-mode-symbolic</property> <property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="action_name">app.dark-mode</property>
<property name="tooltip_text" translatable="yes">Toggle Dark Mode</property>
<child>
<object class="GtkImage" id="dark_mode_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">dark-mode-symbolic</property>
</object>
</child>
</object> </object>
<packing>
<property name="pack_type">start</property>
</packing>
</child> </child>
</object>
<packing>
<property name="pack_type">start</property>
</packing>
</child>
<child>
<object class="GtkMenuButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="popover">popover</property>
<child> <child>
<object class="GtkImage"> <object class="GtkMenuButton">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="icon_name">open-menu-symbolic</property> <property name="receives_default">True</property>
<property name="popover">popover</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">open-menu-symbolic</property>
</object>
</child>
</object> </object>
<packing>
<property name="pack_type">end</property>
</packing>
</child> </child>
</object> </object>
<packing>
<property name="pack_type">end</property>
</packing>
</child> </child>
</object> </object>
</child> </child>
......
...@@ -12,13 +12,13 @@ use std::{cell::RefCell, rc::Rc}; ...@@ -12,13 +12,13 @@ use std::{cell::RefCell, rc::Rc};
#[derive(Clone)] #[derive(Clone)]
pub struct SearchProvider { pub struct SearchProvider {
search_provider: Arc<SP>, search_provider: Arc<SP>,
window: gtk::ApplicationWindow, window: libhandy::ApplicationWindow,
sender: Sender<Action>, sender: Sender<Action>,
model: Rc<IconsModel>, model: Rc<IconsModel>,
} }
impl SearchProvider { impl SearchProvider {
pub fn new(model: Rc<IconsModel>, window: gtk::ApplicationWindow, sender: Sender<Action>) -> Rc<RefCell<Self>> { pub fn new(model: Rc<IconsModel>, window: libhandy::ApplicationWindow, sender: Sender<Action>) -> Rc<RefCell<Self>> {
let search_provider = SP::new(APP_ID.to_string(), "/org/gnome/design/IconLibrary/SearchProvider".to_string()); let search_provider = SP::new(APP_ID.to_string(), "/org/gnome/design/IconLibrary/SearchProvider".to_string());
let sp = Rc::new(RefCell::new(Self { let sp = Rc::new(RefCell::new(Self {
......
...@@ -7,7 +7,7 @@ use gtk::prelude::*; ...@@ -7,7 +7,7 @@ use gtk::prelude::*;
use std::rc::Rc; use std::rc::Rc;
pub struct Window { pub struct Window {
pub widget: gtk::ApplicationWindow, pub widget: libhandy::ApplicationWindow,
builder: gtk::Builder, builder: gtk::Builder,
sender: glib::Sender<Action>, sender: glib::Sender<Action>,
pub model: Rc<IconsModel>, pub model: Rc<IconsModel>,
...@@ -17,7 +17,7 @@ impl Window { ...@@ -17,7 +17,7 @@ impl Window {
pub fn new(sender: glib::Sender<Action>, model: Rc<IconsModel>) -> Self { pub fn new(sender: glib::Sender<Action>, model: Rc<IconsModel>) -> Self {
let settings = gio::Settings::new(APP_ID); let settings = gio::Settings::new(APP_ID);
let builder = gtk::Builder::from_resource("/org/gnome/design/IconLibrary/window.ui"); let builder = gtk::Builder::from_resource("/org/gnome/design/IconLibrary/window.ui");
get_widget!(builder, gtk::ApplicationWindow, window); get_widget!(builder, libhandy::ApplicationWindow, window);
let window_widget = Window { let window_widget = Window {
widget: window, widget: window,
...@@ -67,7 +67,8 @@ impl Window { ...@@ -67,7 +67,8 @@ impl Window {
for (_, icons_context) in self.model.shipped_icons.borrow().iter() { for (_, icons_context) in self.model.shipped_icons.borrow().iter() {
icons_view.add_context(icons_context.clone()); icons_view.add_context(icons_context.clone());
} }
self.widget.add(&icons_view.widget); get_widget!(self.builder, gtk::Box, container);
container.add(&icons_view.widget);
// Search // Search
get_widget!(self.builder, gtk::SearchEntry, search_entry); get_widget!(self.builder, gtk::SearchEntry, search_entry);
......
...@@ -3,7 +3,7 @@ use gio::prelude::SettingsExt; ...@@ -3,7 +3,7 @@ use gio::prelude::SettingsExt;
use gtk::prelude::GtkWindowExt; use gtk::prelude::GtkWindowExt;
use gtk::SettingsExt as gtkSettingsExt; use gtk::SettingsExt as gtkSettingsExt;
pub fn load(window: &gtk::ApplicationWindow, settings: &gio::Settings) { pub fn load(window: &libhandy::ApplicationWindow, settings: &gio::Settings) {
let width = settings.get_int("window-width"); let width = settings.get_int("window-width");
let height = settings.get_int("window-height"); let height = settings.get_int("window-height");
...@@ -28,7 +28,7 @@ pub fn load(window: &gtk::ApplicationWindow, settings: &gio::Settings) { ...@@ -28,7 +28,7 @@ pub fn load(window: &gtk::ApplicationWindow, settings: &gio::Settings) {
} }
} }
pub fn save(window: &gtk::ApplicationWindow, settings: &gio::Settings) -> Result<()> { pub fn save(window: &libhandy::ApplicationWindow, settings: &gio::Settings) -> Result<()> {
let size = window.get_size(); let size = window.get_size();
let position = window.get_position(); let position = window.get_position();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment