Commit a13a5c0e authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui
Browse files

WIP

parent f4519d57
Pipeline #96661 failed with stages
in 1 minute and 8 seconds
......@@ -262,6 +262,7 @@ dependencies = [
"gio 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glib 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gtk 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libhandy 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -275,6 +276,42 @@ name = "libc"
version = "0.2.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libhandy"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gdk 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gdk-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gio 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gio-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glib 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gtk 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gtk-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)",
"libhandy-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libhandy-sys"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gdk 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gdk-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gio 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gio-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gtk-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "locale_config"
version = "0.2.3"
......@@ -410,6 +447,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum gtk-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "849835f05d46f605b00ee9fefb6d5921238c570af406f35ee7426ed01cd6795c"
"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14"
"checksum libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)" = "3262021842bf00fe07dbd6cf34ff25c99d7a7ebef8deea84db72be3ea3bb0aff"
"checksum libhandy 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9f1fd41f2216fc3894257f4b4405dec7255977ff3a292df1ec1a74bc1700178d"
"checksum libhandy-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d1a46914f15afb94df8efddd8d451f60764da95a63dc4f7f3526ce71e1ef775"
"checksum locale_config 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "73ac19ebe45489e5d53b4346d8b90bb3dd03275c5fdf2ce22a982516d86b535c"
"checksum log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c275b6ad54070ac2d665eef9197db647b32239c9d244bfb6f041a766d00da5b3"
"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e"
......
......@@ -11,3 +11,4 @@ gio = { version = "0.6.0", features = ["v2_46"] }
gdk = "0.10.0"
log = "0.4"
gettext-rs= { version = "0.4.1", features = ["gettext-system"] }
libhandy = "0.3.0"
......@@ -31,6 +31,28 @@
}
},
"modules" : [
{
"name" : "libhandy",
"buildsystem" : "meson",
"config-opts" : [
"-Dintrospection=enabled",
"-Dgtk_doc=false",
"-Dtests=false",
"-Dexamples=false",
"-Dvapi=false",
"-Dglade_catalog=disabled"
],
"cleanup" : [
"/include",
"/lib/pkgconfig"
],
"sources" : [
{
"type" : "git",
"url" : "https://source.puri.sm/Librem5/libhandy.git"
}
]
},
{
"name" : "icons-finder",
"buildsystem" : "meson",
......
{
"app-id": "com.bilelmoussaoui.IconsFinderDevel",
"app-id": "com.bilelmoussaoui.IconsFinderDevel",
"runtime" : "org.gnome.Platform",
"runtime-version" : "master",
"runtime-version" : "3.32",
"sdk" : "org.gnome.Sdk",
"sdk-extensions" : [
"org.freedesktop.Sdk.Extension.rust-stable"
......@@ -36,7 +36,29 @@
},
"modules" : [
{
"name" : "gtk-rust-template",
"name" : "libhandy",
"buildsystem" : "meson",
"config-opts" : [
"-Dintrospection=enabled",
"-Dgtk_doc=false",
"-Dtests=false",
"-Dexamples=false",
"-Dvapi=false",
"-Dglade_catalog=disabled"
],
"cleanup" : [
"/include",
"/lib/pkgconfig"
],
"sources" : [
{
"type" : "git",
"url" : "https://source.puri.sm/Librem5/libhandy.git"
}
]
},
{
"name" : "icons-finder",
"buildsystem" : "meson",
"config-opts" : [
"-Dprofile=development"
......
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/com/bilelmoussaoui/GtkRustTemplate/">
<gresource prefix="/com/bilelmoussaoui/IconsFinder/">
<file compressed="true" preprocess="xml-stripblanks">about_dialog.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>
......
.title-header{
font-size: 36px;
.icons-view-title {
font-size: 16px;
font-weight: bold;
padding: 6px;
}
......@@ -6,13 +6,13 @@
<property name="can_focus">False</property>
<property name="modal">True</property>
<property name="type_hint">dialog</property>
<property name="program_name">GTK Rust Template</property>
<property name="program_name">Icons Finder</property>
<property name="version">@version@</property>
<property name="website">https://gitlab.gnome.org/bilelmoussaoui/gtk-rust-template/</property>
<property name="website">https://gitlab.gnome.org/bilelmoussaoui/icons-finder/</property>
<property name="authors">Bilal Elmoussaoui</property>
<property name="translator_credits" translatable="yes">translator-credits</property>
<property name="logo_icon_name">@app-id@</property>
<property name="license_type">mit-x11</property>
<property name="license_type">gpl-3-0-only</property>
<child type="titlebar">
<placeholder/>
</child>
......
......@@ -9,20 +9,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkModelButton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">False</property>
<property name="action_name">app.preferences</property>
<property name="text" translatable="yes">Preferences</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkModelButton">
<property name="visible">True</property>
......@@ -43,7 +29,7 @@
<property name="can_focus">False</property>
<property name="receives_default">False</property>
<property name="action_name">app.about</property>
<property name="text" translatable="yes">About GTK Rust Template</property>
<property name="text" translatable="yes">About Icons Finder</property>
</object>
<packing>
<property name="expand">False</property>
......
......@@ -2,6 +2,7 @@
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<requires lib="libhandy" version="0.0"/>
<object class="GtkApplicationWindow" id="window">
<property name="can_focus">False</property>
<property name="default_width">600</property>
......@@ -11,8 +12,26 @@
<object class="GtkHeaderBar" id="headerbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">GTK + Rust Application Template</property>
<property name="show_close_button">True</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>
<child>
<object class="GtkSearchEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">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>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuButton" id="appmenu_button">
<property name="visible">True</property>
......@@ -33,14 +52,7 @@
</object>
</child>
<child>
<object class="GtkLabel" id="label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Hello world!</property>
<style>
<class name="title-header"/>
</style>
</object>
<placeholder/>
</child>
</object>
</interface>
......@@ -7,6 +7,7 @@ dependency('glib-2.0', version: '>= 2.56')
dependency('gio-2.0', version: '>= 2.56')
dependency('gdk-pixbuf-2.0')
dependency('gtk+-3.0', version: '>= 3.24.7')
dependency('libhandy-0.0', version: '>= 0.0.10')
version = meson.project_version()
......
......@@ -15,10 +15,10 @@ impl Application {
let app = gtk::Application::new(config::APP_ID, gio::ApplicationFlags::FLAGS_NONE).unwrap();
let window = Window::new();
glib::set_application_name(&format!("GtkRustTemplate{}", config::NAME_SUFFIX));
glib::set_prgname(Some("rust-gtk-template"));
glib::set_application_name(&format!("IconsFinder{}", config::NAME_SUFFIX));
glib::set_prgname(Some("icons-finder"));
let builder = gtk::Builder::new_from_resource("/com/bilelmoussaoui/GtkRustTemplate/shortcuts.ui");
let builder = gtk::Builder::new_from_resource("/com/bilelmoussaoui/IconsFinder/shortcuts.ui");
let dialog: gtk::ShortcutsWindow = builder.get_object("shortcuts").unwrap();
window.widget.set_help_overlay(Some(&dialog));
......@@ -39,7 +39,7 @@ impl Application {
// About
let window = self.window.widget.clone();
self.add_gaction("about", move |_, _| {
let builder = gtk::Builder::new_from_resource("/com/bilelmoussaoui/GtkRustTemplate/about_dialog.ui");
let builder = gtk::Builder::new_from_resource("/com/bilelmoussaoui/IconsFinder/about_dialog.ui");
let about_dialog: gtk::AboutDialog = builder.get_object("about_dialog").unwrap();
about_dialog.set_transient_for(&window);
......@@ -69,12 +69,12 @@ impl Application {
pub fn setup_css(&self) {
let p = gtk::CssProvider::new();
gtk::CssProvider::load_from_resource(&p, "/com/bilelmoussaoui/GtkRustTemplate/style.css");
gtk::CssProvider::load_from_resource(&p, "/com/bilelmoussaoui/IconsFinder/style.css");
gtk::StyleContext::add_provider_for_screen(&gdk::Screen::get_default().unwrap(), &p, 500);
}
pub fn run(&self) {
info!("GtkRustTemplate{} ({})", config::NAME_SUFFIX, config::APP_ID);
info!("Icons Finder {} ({})", config::NAME_SUFFIX, config::APP_ID);
info!("Version: {} ({})", config::VERSION, config::PROFILE);
info!("Datadir: {}", config::PKGDATADIR);
......
......@@ -4,12 +4,14 @@ extern crate log;
extern crate gio;
extern crate glib;
extern crate gtk;
extern crate libhandy;
use gettextrs::*;
mod application;
mod config;
mod static_resources;
mod widgets;
mod window;
mod window_state;
......
......@@ -36,6 +36,8 @@ run_command(
)
sources = files(
'widgets/icons.rs',
'widgets/mod.rs',
'application.rs',
'config.rs',
'main.rs',
......
use gtk::prelude::{BoxExt, ContainerExt, IconThemeExt, StyleContextExt, WidgetExt};
use gtk::{Box, FlowBox, IconSize, IconTheme, Label, NONE_ADJUSTMENT};
struct IconView {
pub widget: gtk::Box,
icon_name: String,
}
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);
container.pack_start(&icon_img, false, false, 0);
// container.pack_start(&icon_label, false, false, 0);
IconView {
widget: container,
icon_name: icon_name,
}
}
}
pub struct IconsView {
pub widget: gtk::Box,
pub context: String,
}
impl IconsView {
pub fn new(context: String) -> IconsView {
let widget = gtk::Box::new(gtk::Orientation::Vertical, 6);
widget.set_valign(gtk::Align::Fill);
widget.set_halign(gtk::Align::Fill);
let icons_view = IconsView { widget, context };
icons_view.init();
icons_view.fill();
icons_view
}
fn init(&self) {
let context_label = gtk::Label::new(Some(self.context.as_str()));
context_label.set_halign(gtk::Align::Start);
context_label.get_style_context().add_class("icons-view-title");
self.widget.add(&context_label);
}
fn fill(&self) {
let theme = gtk::IconTheme::get_default();
let icons = theme.unwrap().list_icons(Some(self.context.as_str()));
let icons_container = gtk::FlowBox::new();
icons_container.set_valign(gtk::Align::Fill);
icons_container.set_halign(gtk::Align::Fill);
for icon in icons.iter() {
let icon_view = IconView::new(icon.to_string());
icons_container.add(&icon_view.widget);
}
self.widget.add(&icons_container);
}
}
mod icons;
pub(crate) use self::icons::IconsView;
use gtk::prelude::*;
use libhandy::{Column, ColumnExt};
use crate::config::{APP_ID, PROFILE};
use crate::widgets::IconsView;
use crate::window_state;
pub struct Window {
......@@ -11,13 +13,14 @@ pub struct Window {
impl Window {
pub fn new() -> Self {
let settings = gio::Settings::new(APP_ID);
let builder = gtk::Builder::new_from_resource("/com/bilelmoussaoui/GtkRustTemplate/window.ui");
let builder = gtk::Builder::new_from_resource("/com/bilelmoussaoui/IconsFinder/window.ui");
let window_widget: gtk::ApplicationWindow = builder.get_object("window").unwrap();
let appmenu_btn: gtk::MenuButton = builder.get_object("appmenu_button").unwrap();
if PROFILE == "Devel" {
window_widget.get_style_context().add_class("devel");
}
let main_stack = gtk::Stack::new();
let window = Window {
widget: window_widget,
......@@ -30,7 +33,8 @@ impl Window {
pub fn init(&self, settings: gio::Settings) {
// setup app menu
let menu_builder = gtk::Builder::new_from_resource("/com/bilelmoussaoui/GtkRustTemplate/menu.ui");
let menu_builder = gtk::Builder::new_from_resource("/com/bilelmoussaoui/IconsFinder/menu.ui");
let popover_menu: gtk::PopoverMenu = menu_builder.get_object("popover_menu").unwrap();
self.appmenu_button.set_popover(Some(&popover_menu));
// load latest window state
......@@ -41,5 +45,31 @@ impl Window {
window_state::save(&window, &settings);
Inhibit(false)
});
// Init the widgets
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();
let icons_view = IconsView::new(context_str.to_string());
container.pack_start(&icons_view.widget, true, true, 0);
}
let column = Column::new();
column.set_maximum_width(700);
let scrolled_window = gtk::ScrolledWindow::new(gtk::NONE_ADJUSTMENT, gtk::NONE_ADJUSTMENT);
scrolled_window.set_vexpand(true);
scrolled_window.add(&column);
// we can't call add as libhandy::Column is not seen as a gtkContainer
let column = column.upcast::<gtk::Widget>();
let column = column.downcast::<gtk::Container>().unwrap();
column.add(&container);
self.widget.add(&scrolled_window);
self.widget.show_all();
}
}
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