Skip to content
This repository has been archived by the owner on Oct 15, 2023. It is now read-only.

Commit

Permalink
Renamed dirs and removed unrequired UI buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
adhadse committed Oct 17, 2022
1 parent 034cb59 commit 112a82f
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 125 deletions.
11 changes: 0 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,7 @@ features = ["v2_70"]
[dependencies.adw]
package = "libadwaita"
version = "0.1.1"
# features = ["v1_2"]

[dependencies.gettext-rs]
version = "0.7.0"
features = ["gettext-system"]

[dependencies.diesel]
package = "diesel"
version = "1.4"
features = ["sqlite", "r2d2", "chrono"]

[dependencies.diesel_migrations]
package = "diesel_migrations"
version = "1.4"
features = ["sqlite"]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "com.adhadse.bookx.Devel",
"id": "com.adhadse.Bookx.Devel",
"runtime": "org.gnome.Platform",
"runtime-version": "42",
"sdk": "org.gnome.Sdk",
Expand Down
7 changes: 4 additions & 3 deletions data/com.adhadse.Bookx.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
<gresource prefix="/com/adhadse/Bookx/">
<!-- see https://gtk-rs.org/gtk4-rs/git/docs/gtk4/struct.Application.html#automatic-resources -->
<file compressed="true" preprocess="xml-stripblanks" alias="gtk/help-overlay.ui">ui/shortcuts.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/window.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/library.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/library_carousal.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/library_carousal_component.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/library_content_box.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/window.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/preferences.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/shortcuts.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/subpage_library_carousal_page.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/subpage_library_content_page.ui</file>
<file compressed="true">style.css</file>
</gresource>
</gresources>
Expand Down
18 changes: 1 addition & 17 deletions data/ui/library.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,7 @@
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow">
<property name="vexpand">True</property>
<child>
<object class="AdwClamp">
<property name="maximum_size">1600</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="margin_start">12</property>
<property name="margin_end">12</property>
<child>
<object class="GtkBox"></object>
<!-- TODO: create Content box with flap -->
<!-- <object class="SubpageBookxLibraryContentBox" id="content_box"/> -->
</child>
</object>
</child>
</object>
<!-- <object class="BookxLibraryContentBox"/> -->
</child>
</object>
</property>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="SubpageBookxLibraryCarousel" parent="AdwBin">
<template class="BookxLibraryCarousel" parent="AdwBin">
<property name="child">
<object class="GtkBox">
<property name="orientation">vertical</property>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="SubpageBookxLibraryContentPage" parent="AdwBin">
<template class="BookxLibraryContentBox" parent="AdwBin">
<child>
<object class="GtkScrolledWindow" id="scrolledwindow">
<object class="GtkScrolledWindow">
<property name="hscrollbar_policy">never</property>
<child>
<object class="GtkViewport">
Expand All @@ -21,13 +21,13 @@
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="SubpageBookxLibraryCarousel" id="carousel"/>
<object class="BookxLibraryCarousel" id="library_carousel"/>
</child>
<child>
<object class="AdwFlap" id="bookx_library_content_flap">
<object class="AdwFlap" id="book_details_flap">
<property name="reveal-flap">false</property>
<property name="flap-position">end</property>
<property name="swipe-to-open">true</property>
<property name="swipe-to-open">false</property>
<property name="swipe-to-close">true</property>
<property name="transition-type">over</property>
<property name="fold-policy">always</property>
Expand All @@ -38,7 +38,7 @@
</object>
</property>
<property name="flap">
<object class="GtkLabel" id="info_flap">
<object class="GtkLabel">
<property name="label" translatable="yes">Flap</property>
<style><class name="title-header"/></style>
<style><class name="background"/></style>
Expand Down
41 changes: 1 addition & 40 deletions data/ui/window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,8 @@
<property name="icon_name">go-previous-symbolic</property>
</object>
</child>
<child>
<object class="GtkRevealer" id="book_read_button_revealer">
<property name="transition_type">crossfade</property>
<child>
<object class="GtkToggleButton" id="book_read_button">
<property name="icon_name">accessories-dictionary-symbolic</property>
<property name="tooltip-text" translatable="yes">Read Book</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkRevealer" id="book_edit_button_revealer">
<property name="transition_type">crossfade</property>
<child>
<object class="GtkToggleButton" id="book_edit_button">
<property name="icon_name">document-edit-symbolic</property>
<property name="tooltip-text" translatable="yes">Edit Book</property>
</object>
</child>
</object>
</child>

<!-- Search bar, book info, and menu button -->
<!-- Search bar and menu button -->
<!-- Application Menu Button -->
<child type="end">
<object class="GtkMenuButton" id="appmenu_button">
Expand Down Expand Up @@ -79,23 +57,6 @@
</child>
</object>
</child>
<!-- Book Info reveal button -->
<child type="end">
<object class="GtkRevealer" id="book_info_button_revealer">
<property name="transition_type">crossfade</property>
<property name="reveal-child">true</property>
<child>
<object class="GtkToggleButton" id="book_info_button">
<property name="icon_name">info-symbolic</property>
<property name="tooltip-text" translatable="yes">Book Info</property>
<!-- TODO: Bind this button with library's content flap to reveal book info -->
<!-- <property name="active" bind-source="bookx_library_content_flap" -->
<!-- bind-property="reveal-flap" -->
<!-- bind-flags="bidirectional"/> -->
</object>
</child>
</object>
</child>
</object>
</child>

Expand Down
3 changes: 2 additions & 1 deletion src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ impl BookxApplication {
}

fn show_about(&self) {
// Uncomment and delete the similar code when libadwaita 0.2 comes out of alpha release
// TODO: sudo dnf info libadwaita-devel for 1.2
// Uncomment and delete the similar code when libadwaita-devel 1.2 comes out
// let about = adw::AboutWindow::builder()
// .application_icon("Bookx")
// .application_icon(config::APP_ID)
Expand Down
7 changes: 3 additions & 4 deletions src/library/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use crate::application::Action;
use crate::library::utils;
use crate::library::utils::*;
use crate::library::utils::{self, *};
// use crate::library::utils::*;
use crate::settings::{settings_manager, Key};
use crate::ui::BookxWindow;

Expand All @@ -25,10 +25,9 @@ use std::cell::RefCell;
use glib::{
clone, Enum, ObjectExt, ParamFlags, ParamSpec, ParamSpecEnum, ParamSpecObject, Sender, ToValue,
};
use gtk::glib;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use gtk::{gdk_pixbuf, glib};
use gtk_macros::*;
use log::{debug, error, info};
use once_cell::sync::Lazy;
use once_cell::unsync::OnceCell;
Expand Down
16 changes: 9 additions & 7 deletions src/library/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use core::cmp::Ordering;
use std::path::PathBuf;

use enum_map::{enum_map, Enum, EnumArray, EnumMap};
use gtk::{gdk, gio, glib, prelude::*};
use log::{debug, warn};

#[derive(Debug, Enum)]
use gtk::{
gio,
glib::{self, Enum},
prelude::*,
};
use log::debug;

#[derive(Debug, Enum, Clone, Copy)]
#[enum_type(name = "EBook")]
pub enum EBook {
Epub,
}
Expand Down
9 changes: 5 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mod settings;
mod ui;

use application::BookxApplication;
use gettextrs::*;
use gettextrs;

mod deps {
pub use gtk::{gdk, gdk_pixbuf, gio, glib, graphene};
Expand All @@ -34,9 +34,10 @@ fn main() {
pretty_env_logger::init();

// Prepare i18n
setlocale(LocaleCategory::LcAll, "");
bindtextdomain(config::PKGNAME, config::LOCALEDIR).expect("Unable to bind the text domain");
textdomain(config::PKGNAME).expect("Unable to switch to the text domain");
gettextrs::setlocale(gettextrs::LocaleCategory::LcAll, "");
gettextrs::bindtextdomain(config::PKGNAME, config::LOCALEDIR)
.expect("Unable to bind the text domain");
gettextrs::textdomain(config::PKGNAME).expect("Unable to switch to the text domain");

// Load app resources
let path = &format!(
Expand Down
2 changes: 1 addition & 1 deletion src/ui/pages/library.rs → src/ui/library/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ mod imp {

glib::wrapper! {
pub struct BookxLibraryPage(ObjectSubclass<imp::BookxLibraryPage>)
@extends gtk::Widget, adw::Bin;
@extends gtk::Widget, adw::Bin;
}

impl BookxLibraryPage {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

pub mod pages;
pub mod library;

mod window;
pub use window::BookxView;
Expand Down
34 changes: 6 additions & 28 deletions src/ui/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ use crate::config;
use crate::deps::*;
use crate::library::BookxLibraryStatus;
use crate::settings::{settings_manager, Key};
use crate::ui::pages::BookxLibraryPage;
use crate::ui::library::BookxLibraryPage;

use std::cell::RefCell;
use std::rc::Rc;

use adw::subclass::application_window::AdwApplicationWindowImpl;
use adw::subclass::prelude::*;
use glib::{clone, subclass, Enum, ParamFlags, ParamSpec, ParamSpecEnum, Sender, ToValue};
use gtk::{gdk, gio, glib, prelude::*, subclass::prelude::*, CompositeTemplate, Widget};
use gtk::{gdk, gio, glib, prelude::*, subclass::prelude::*, Widget};
use gtk_macros::*;
use log::{debug, info};
use once_cell::sync::Lazy;
Expand All @@ -36,7 +36,7 @@ use strum_macros::*;

#[derive(Display, Copy, Debug, Clone, EnumString, Eq, PartialEq, Enum)]
#[repr(u32)]
#[enum_type(name = "Bookxiew")]
#[enum_type(name = "BookxView")]
pub enum BookxView {
// managed by bookx_window_leaflet
Library,
Expand All @@ -49,21 +49,9 @@ impl Default for BookxView {
}
}

// pub enum BookxMode {
// // managed by bookx_stack
// InitialView, // when no folder is added
// MainView, // when folder is added/known
// }
//
// impl Default for BookxMode {
// fn default() -> Self {
// BookxMode::InitialView
// }
// }

mod imp {
use super::*;
use gtk::pango::Weight::Book;
use gtk::CompositeTemplate;

// To use composite templates, you need
// to use derive macro. Derive macros generate
Expand Down Expand Up @@ -104,12 +92,6 @@ mod imp {

#[template_child]
pub back_button: TemplateChild<gtk::Button>,
#[template_child]
pub book_read_button_revealer: TemplateChild<gtk::Revealer>,
#[template_child]
pub book_edit_button_revealer: TemplateChild<gtk::Revealer>,
#[template_child]
pub book_info_button_revealer: TemplateChild<gtk::Revealer>,

#[template_child]
pub appmenu_button: TemplateChild<gtk::MenuButton>,
Expand Down Expand Up @@ -221,7 +203,7 @@ impl BookxWindow {
}

pub fn setup_widgets(&self, sender: Sender<Action>) {
// Init pages
// Init library
self.imp().library_page.init(sender.clone());

// Add devel style class for development or beta builds
Expand Down Expand Up @@ -252,7 +234,7 @@ impl BookxWindow {
);

// search_button
// TODO: fix search button expantion
// TODO: fix search button expansion
imp.search_button
.connect_toggled(clone!(@strong self as this => move |search_button| {
if search_button.is_active() {
Expand Down Expand Up @@ -346,10 +328,6 @@ impl BookxWindow {
let view = *imp.view.borrow();
debug!("Set view to {:?}", view);

imp.book_read_button_revealer.set_reveal_child(false);
imp.book_edit_button_revealer.set_reveal_child(false);
imp.book_info_button_revealer.set_reveal_child(false);

match view {
BookxView::Library => {
imp.bookx_window_leaflet
Expand Down

0 comments on commit 112a82f

Please sign in to comment.