Commit 9cd52ae3 authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui
Browse files

Prototype UI: ready

parent a13a5c0e
Pipeline #96742 failed with stages
in 1 minute and 8 seconds
......@@ -2,6 +2,7 @@
<gresources>
<gresource prefix="/com/bilelmoussaoui/IconsFinder/">
<file compressed="true" preprocess="xml-stripblanks">about_dialog.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="export_window.ui">resources/ui/export_window.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="shortcuts.ui">resources/ui/shortcuts.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="menu.ui">resources/ui/menu.ui</file>
<file compressed="true" preprocess="xml-stripblanks">window.ui</file>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkWindow" id="export_window">
<property name="can_focus">False</property>
<property name="modal">True</property>
<property name="default_width">400</property>
<property name="default_height">260</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="headerbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="show_close_button">True</property>
</object>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkInfoBar" id="is_system_infobar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="spacing">6</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Copy Icon Name</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child internal-child="content_area">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="spacing">16</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">This is a system icon. It does not need to be shipped with apps.</property>
<property name="wrap">True</property>
<property name="wrap_mode">word-char</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="border_width">18</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="border_width">0</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">end</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkImage" id="icon_size_16">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">16</property>
<property name="icon_name">image-missing-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">12</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="label">16</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">12</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">end</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkImage" id="icon_size_32">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">32</property>
<property name="icon_name">image-missing-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">12</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="label">32</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">12</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">end</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkImage" id="icon_size_64">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">64</property>
<property name="icon_name">image-missing-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">12</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="label">64</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">12</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="hexpand">True</property>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Copy to Clipboard</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">6</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Save as...</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">6</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
......@@ -9,16 +9,17 @@
<property name="default_height">400</property>
<property name="icon_name">@app-id@</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="headerbar">
<object class="HdyHeaderBar" id="headerbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="show_close_button">True</property>
<property name="centering_policy">1</property>
<child type="title">
<object class="HdyColumn">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="maximum_width">700</property>
<property name="linear_growth_width">700</property>
<property name="maximum_width">400</property>
<property name="linear_growth_width">400</property>
<child>
<object class="GtkSearchEntry">
<property name="visible">True</property>
......
......@@ -37,6 +37,7 @@ run_command(
sources = files(
'widgets/icons.rs',
'widgets/export.rs',
'widgets/mod.rs',
'application.rs',
'config.rs',
......
use gtk::prelude::{HeaderBarExt, ImageExt, WidgetExt};
use gtk::{IconSize, Window};
pub struct ExportDialog {
pub widget: gtk::Window,
headerbar: gtk::HeaderBar,
icon_name: String,
icon_size_16: gtk::Image,
icon_size_32: gtk::Image,
icon_size_64: gtk::Image,
is_system_icon: bool,
}
impl ExportDialog {
pub fn new(icon_name: String) -> ExportDialog {
let builder = gtk::Builder::new_from_resource("/com/bilelmoussaoui/IconsFinder/export_window.ui");
let window_widget: gtk::Window = builder.get_object("export_window").unwrap();
let icon_size_16: gtk::Image = builder.get_object("icon_size_16").unwrap();
let icon_size_32: gtk::Image = builder.get_object("icon_size_32").unwrap();
let icon_size_64: gtk::Image = builder.get_object("icon_size_64").unwrap();
let headerbar: gtk::HeaderBar = builder.get_object("headerbar").unwrap();
let export_dialog = ExportDialog {
widget: window_widget,
headerbar: headerbar,
icon_name: icon_name,
icon_size_16: icon_size_16,
icon_size_32: icon_size_32,
icon_size_64: icon_size_64,
is_system_icon: true, // Currently we only show Adwaita icon, revisit that later
};
export_dialog.init();
export_dialog
}
fn init(&self) {
let icon_str = Some(self.icon_name.as_str());
self.icon_size_16.set_from_icon_name(icon_str, gtk::IconSize::Button);
self.icon_size_32.set_from_icon_name(icon_str, gtk::IconSize::Dnd);
self.icon_size_64.set_from_icon_name(icon_str, gtk::IconSize::Dialog);
self.headerbar.set_title(icon_str);
self.widget.show_all();
}
}
use gtk::prelude::{BoxExt, ContainerExt, IconThemeExt, StyleContextExt, WidgetExt};
use gtk::prelude::{BoxExt, ContainerExt, FlowBoxExt, IconThemeExt, ImageExt, StyleContextExt, WidgetExt};
use gtk::{Box, FlowBox, IconSize, IconTheme, Label, NONE_ADJUSTMENT};
use crate::widgets::export::ExportDialog;
struct IconView {
pub widget: gtk::Box,
icon_name: String,
......@@ -10,11 +12,13 @@ impl IconView {
pub fn new(icon_name: String) -> IconView {
let container = gtk::Box::new(gtk::Orientation::Vertical, 6);
let icon_label = gtk::Label::new(Some(icon_name.as_str()));
let icon_img = gtk::Image::new_from_icon_name(Some(icon_name.as_str()), gtk::IconSize::Button);
let icon_img = gtk::Image::new_from_icon_name(Some(icon_name.as_str()), gtk::IconSize::Dnd);
container.pack_start(&icon_img, false, false, 0);
// container.pack_start(&icon_label, false, false, 0);
/*
container.pack_start(&icon_label, false, false, 0);
container.pack_start(&icon_label, false, false, 0);
*/
IconView {
widget: container,
......@@ -52,12 +56,28 @@ impl IconsView {
fn fill(&self) {
let theme = gtk::IconTheme::get_default();
let icons = theme.unwrap().list_icons(Some(self.context.as_str()));
let icons_blacklist = vec![""];
let icons_container = gtk::FlowBox::new();
icons_container.set_valign(gtk::Align::Fill);
icons_container.set_halign(gtk::Align::Fill);
icons_container.set_row_spacing(12);
icons_container.set_column_spacing(12);
icons_container.set_max_children_per_line(14);
icons_container.set_selection_mode(gtk::SelectionMode::None);
icons_container.connect_child_activated(move |child, _| {
let export_dialog = ExportDialog::new(String::from("document-save-symbolic"));
//println!("hey sister {}", child.);
});
for icon in icons.iter() {
let icon_view = IconView::new(icon.to_string());
icons_container.add(&icon_view.widget);
let icon_name = icon.to_string();
if icon_name.ends_with("-symbolic") {
let icon_view = IconView::new(icon_name);
icons_container.add(&icon_view.widget);
}
}
self.widget.add(&icons_container);
}
......
mod export;
mod icons;
pub(crate) use self::export::ExportDialog;
pub(crate) use self::icons::IconsView;
......@@ -46,19 +46,21 @@ impl Window {
Inhibit(false)
});
// Init the widgets
let legacy_contexts = vec!["Legacy"];
let container = gtk::Box::new(gtk::Orientation::Vertical, 0);
let theme = gtk::IconTheme::get_default().unwrap();
let icon_contexts = theme.list_contexts();
for context in icon_contexts.iter() {
let context_str = context.as_str();
if legacy_contexts.contains(&context_str) {
continue;
}
let icons_view = IconsView::new(context_str.to_string());
container.pack_start(&icons_view.widget, true, true, 0);
container.pack_start(&icons_view.widget, true, true, 12);
}
let column = Column::new();
column.set_maximum_width(700);
column.set_maximum_width(900);
let scrolled_window = gtk::ScrolledWindow::new(gtk::NONE_ADJUSTMENT, gtk::NONE_ADJUSTMENT);
scrolled_window.set_vexpand(true);
......
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