Skip to content

Commit

Permalink
chore: update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mmstick committed Apr 14, 2023
1 parent bdc9893 commit 1eeb51f
Show file tree
Hide file tree
Showing 10 changed files with 885 additions and 510 deletions.
1,263 changes: 828 additions & 435 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@ license-file = "LICENSE"
readme = "README.md"
repository = "https://github.com/mmstick/fontfinder"
version = "2.1.0"
edition = "2021"

[workspace]
members = ["gtk"]

[dependencies]
anyhow = "1.0"
async-process = "1.0"
async-process = "1.7"
horrorshow = "0.8"
i18n-embed = { version = "0.12", features = ["fluent-system", "desktop-requester"] }
i18n-embed-fl = "0.5"
i18n-embed = { version = "0.13.8", features = ["fluent-system", "desktop-requester"] }
i18n-embed-fl = "0.6.6"
itertools = "0.10"
lazy_static = "1.4"
once_cell = "1.7"
rust-embed = "5.9"
once_cell = "1.17"
rust-embed = "6.6.1"
serde = { version = "1.0", features = ["derive"]}
serde_json = "1.0"
ureq = { version = "2.1", features = ["json"]}
dirs = "4.0.0"
ureq = { version = "2.6", features = ["json"]}
dirs = "5.0.0"
20 changes: 10 additions & 10 deletions gtk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ description = "GTK3 Font Finding GUI Application"
license-file = "LICENSE"
readme = "README.md"
repository = "https://github.com/mmstick/fontfinder"
version = "2.0.0"
version = "2.1.0"
edition = "2018"

[dependencies]
async-channel = "1.6"
async-channel = "1.8"
cascade = "1.0"
closure = "0.3"
fontfinder = { path = ".." }
futures = "0.3"
gio = "0.9"
glib = "0.10"
gtk = { version = "0.9", features = ["v3_22"] }
i18n-embed = { version = "0.12", features = ["fluent-system", "desktop-requester"] }
i18n-embed-fl = "0.5"
once_cell = "1.7"
rust-embed = "5.9"
webkit2gtk = { version = "0.11", features = ["v2_16"] }
gio = "0.16.7"
glib = "0.16.7"
gtk = { version = "0.16.2" }
i18n-embed = { version = "0.13.8", features = ["fluent-system", "desktop-requester"] }
i18n-embed-fl = "0.6.6"
once_cell = "1.17"
rust-embed = "6.6.1"
webkit2gtk = { version = "1.0.0", features = ["v2_16"] }
7 changes: 3 additions & 4 deletions gtk/src/app/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ use crate::utils::{block_on, set_margin};
use crate::{fl, Event};
use async_channel::Sender;
use fontfinder::fonts::{Font, Sorting};
use gtk;
use gtk::prelude::*;
use std::rc::Rc;
use webkit2gtk::*;
use webkit2gtk::{glib, UserContentManager, WebContext, WebView, WebViewExtManual};

#[derive(Clone)]
pub struct Main {
Expand Down Expand Up @@ -47,7 +46,7 @@ impl Main {
..append_text(&fl!("sort-by-alphabetical"));
..set_active(Some(0));
..connect_changed(closure!(clone tx, |sort_by| {
let event = Event::Sort(match sort_by.get_active() {
let event = Event::Sort(match sort_by.active() {
Some(0) => Sorting::Trending,
Some(1) => Sorting::Popular,
Some(2) => Sorting::DateAdded,
Expand Down Expand Up @@ -79,7 +78,7 @@ impl Main {
};

// Initializes the webkit2gtk preview that will display the fonts.
let context = WebContext::get_default().unwrap();
let context = WebContext::default().unwrap();
let view = WebView::new_with_context_and_user_content_manager(
&context,
&UserContentManager::new(),
Expand Down
26 changes: 13 additions & 13 deletions gtk/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ use fontfinder::{
fonts::{self, FontsList, Sorting},
html,
};
use gtk;

use gtk::prelude::*;
use gtk::WidgetExt;
use webkit2gtk::*;
use gtk::traits::WidgetExt;
use webkit2gtk::WebViewExt;

use crate::utils::{get_buffer, get_search, spawn_local};
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -48,7 +48,7 @@ impl App {
let path = match dirs::font_cache() {
Ok(path) => path,
Err(why) => {
eprintln!("{}", why);
eprintln!("{why}");
std::process::exit(1);
}
};
Expand All @@ -57,7 +57,7 @@ impl App {
let fonts = match fonts::obtain(Sorting::Trending) {
Ok(fonts) => fonts,
Err(why) => {
eprintln!("failed to get font archive: {:?}", why);
eprintln!("failed to get font archive: {why:?}");
std::process::exit(1);
}
};
Expand Down Expand Up @@ -108,7 +108,7 @@ impl App {
Ok(_) => {
self.header.install.set_visible(false);
self.header.uninstall.set_visible(true);
font.set_visible(self.header.show_installed.get_active());
font.set_visible(self.header.show_installed.is_active());

let tx = self.state.tx.clone();
let _ = spawn_local(async move {
Expand All @@ -127,13 +127,13 @@ impl App {
let path = &self.state.path;
let fonts = &self.state.fonts;

if let Some(category) = self.main.categories.get_active_text() {
if let Some(category) = self.main.categories.active_text() {
filter_category(
&category,
get_search(&self.main.search).as_ref().map(|x| x.as_str()),
&self.main.fonts.get_rows(),
|family| {
self.header.show_installed.get_active() || !is_installed(fonts, family, path)
self.header.show_installed.is_active() || !is_installed(fonts, family, path)
},
);
}
Expand Down Expand Up @@ -191,7 +191,7 @@ impl App {
*fonts = match fontfinder::fonts::obtain(sorting) {
Ok(fonts) => fonts,
Err(why) => {
eprintln!("failed to get font archive: {}", why);
eprintln!("failed to get font archive: {why}");
return;
}
};
Expand All @@ -216,7 +216,7 @@ impl App {
eprintln!("{} uninstalled", &font.family);
}
Err(why) => {
eprintln!("unable to remove font: {}", why);
eprintln!("unable to remove font: {why}");
}
}
}
Expand All @@ -228,9 +228,9 @@ impl App {
html::generate(
&font.family,
&font.variants,
self.header.font_size.get_value(),
self.header.font_size.value(),
&sample_text[..],
self.header.dark_preview.get_active(),
self.header.dark_preview.is_active(),
|html| self.main.view.load_html(html, None),
);
}
Expand All @@ -249,7 +249,7 @@ where
&& search.as_ref().map_or(true, |s| font.contains(s));

font.set_visible(visible && installed(&font.family));
})
});
}

/// Evaluates whether each variant of a given font family is locally installed.
Expand Down
19 changes: 9 additions & 10 deletions gtk/src/app/widgets/fontlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::utils::block_on;
use crate::Event;

use fontfinder::fonts::Font;
use gtk;
use gtk::prelude::*;
use std::cell::{Ref, RefCell};
use std::ops::Deref;
Expand All @@ -22,18 +21,18 @@ impl FontList {
gtk::ListBox::new();
..connect_row_selected(move |_, row| {
if let Some(row) = row.as_ref() {
let _ = block_on(tx.send(Event::Select(row.get_index() as usize)));
let _ = block_on(tx.send(Event::Select(row.index() as usize)));
}
});
};

// Allows the font list box to scroll
let scroller = cascade! {
gtk::ScrolledWindow::new::<gtk::Adjustment, gtk::Adjustment>(None, None);
..set_property_hscrollbar_policy(gtk::PolicyType::Never);
..set_min_content_width(200);
..add(&container);
};
let scroller = gtk::ScrolledWindow::builder()
.hscrollbar_policy(gtk::PolicyType::Never)
.min_content_width(200)
.build();

scroller.add(&container);

let list = FontList {
container,
Expand All @@ -47,7 +46,7 @@ impl FontList {

pub fn update(&self, fonts_archive: &[Font]) {
self.container
.get_children()
.children()
.iter()
.for_each(|c| unsafe { c.destroy() });
let mut fonts = self.fonts.borrow_mut();
Expand All @@ -66,7 +65,7 @@ impl FontList {
self.container.show_all();
}

pub fn get_rows<'a>(&'a self) -> Ref<'a, Vec<FontRow>> {
pub fn get_rows(&self) -> Ref<Vec<FontRow>> {
self.fonts.borrow()
}
}
Expand Down
3 changes: 1 addition & 2 deletions gtk/src/app/widgets/header.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::utils::{block_on, set_class, set_margin};
use crate::{fl, Event};
use async_channel::Sender;
use gtk;
use gtk::prelude::*;
use std::ops::Deref;

Expand Down Expand Up @@ -53,7 +52,7 @@ impl Header {
0.1,
2,
);
..connect_property_value_notify(closure!(clone tx, |_| {
..connect_value_notify(closure!(clone tx, |_| {
let _ = block_on(tx.send(Event::UpdatePreview));
}));
};
Expand Down
3 changes: 1 addition & 2 deletions gtk/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![allow(unknown_lints)]
#![allow(option_map_unit_fn)]

#[macro_use]
extern crate cascade;
Expand All @@ -24,7 +23,7 @@ fn main() {

for (lib, localizer) in localizers {
if let Err(error) = localizer.select(&requested_languages) {
eprintln!("Error while loading languages for {} {}", lib, error);
eprintln!("Error while loading languages for {lib} {error}");
}
}

Expand Down
10 changes: 5 additions & 5 deletions gtk/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ where

/// Obtains the entire inner string of a given text buffer.
pub fn get_buffer(buffer: &TextBuffer) -> Option<GString> {
let start = buffer.get_start_iter();
let end = buffer.get_end_iter();
buffer.get_text(&start, &end, true)
let start = buffer.start_iter();
let end = buffer.end_iter();
buffer.text(&start, &end, true)
}

/// Obtains the value of the search entry from the UI
pub fn get_search(search: &SearchEntry) -> Option<GString> {
let text = search.get_text();
let text = search.text();
if text.is_empty() {
None
} else {
Expand All @@ -39,7 +39,7 @@ pub fn get_search(search: &SearchEntry) -> Option<GString> {

/// A simple convenience function for adding a style class to a widget.
pub fn set_class<W: WidgetExt>(widget: &W, class: &str) {
widget.get_style_context().add_class(class);
widget.style_context().add_class(class);
}

pub fn set_margin<W: WidgetExt>(widget: &W, t: i32, r: i32, b: i32, l: i32) {
Expand Down
29 changes: 7 additions & 22 deletions src/fonts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,24 @@ use std::io::{self, Write};
const API_KEY: &str = "AIzaSyDpvpba_5RvJSvmXEJS7gZDezDaMlVTo4c";

lazy_static! {
static ref URL_ALPHA: String = {
format!(
"https://www.googleapis.com/webfonts/v1/webfonts?sort=alpha&key={}",
API_KEY
)
};
static ref URL_ALPHA: String =
format!("https://www.googleapis.com/webfonts/v1/webfonts?sort=alpha&key={API_KEY}");
}

lazy_static! {
static ref URL_DATE: String = {
format!(
"https://www.googleapis.com/webfonts/v1/webfonts?sort=date&key={}",
API_KEY
)
};
static ref URL_DATE: String =
format!("https://www.googleapis.com/webfonts/v1/webfonts?sort=date&key={API_KEY}");
}

lazy_static! {
static ref URL_POPULARITY: String = {
format!(
"https://www.googleapis.com/webfonts/v1/webfonts?sort=popularity&key={}",
API_KEY
)
format!("https://www.googleapis.com/webfonts/v1/webfonts?sort=popularity&key={API_KEY}")
};
}

lazy_static! {
static ref URL_TRENDING: String = {
format!(
"https://www.googleapis.com/webfonts/v1/webfonts?sort=trending&key={}",
API_KEY
)
};
static ref URL_TRENDING: String =
format!("https://www.googleapis.com/webfonts/v1/webfonts?sort=trending&key={API_KEY}");
}

/// The JSON response from Google that contains information on Google's font
Expand Down

0 comments on commit 1eeb51f

Please sign in to comment.