Skip to content

Commit

Permalink
[WIP] Messages refactoring.
Browse files Browse the repository at this point in the history
  - Organizing assets (images).
  - Fix for GTK application icons.
  - Improving UX for text entries (default 50 characters)
  - About dialog: showing app icon, acknoledgements and version based on
    git.
  • Loading branch information
Miguel Aranha Baldi Horlle committed May 1, 2024
1 parent 9650e8e commit ba067be
Show file tree
Hide file tree
Showing 14 changed files with 223 additions and 31 deletions.
110 changes: 110 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ csv = "1.3.0"
sasl2-sys = { version = "0.1.20",features = ["openssl-vendored"]}

[build-dependencies]
anyhow = "1.0.51"
openssl-src = { version = "300", default-features = false, features = ["force-engine"] }
vergen = { version = "8.3.1", features = ["build","git","gitcl","si"] }
#glib-build-tools = "0.19.0"

[package.metadata.appimage]
Expand Down
13 changes: 11 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use anyhow::Result;
use std::{env, path::Path, process::Command};
use vergen::EmitBuilder;

// rustdoc-stripper-ignore-next
/// Call to run `glib-compile-resources` to generate compiled gresources to embed
Expand Down Expand Up @@ -54,8 +56,7 @@ pub fn compile_resources<P: AsRef<Path>>(source_dirs: &[P], gresource: &str, tar
}
}


fn main() {
fn main() -> Result<()>{
compile_resources(
&["data"],
"data/resources.gresource.xml",
Expand All @@ -66,4 +67,12 @@ fn main() {
"data/icons.gresource.xml",
"icons.gresource",
);

EmitBuilder::builder()
.all_build()
.all_git()
.all_sysinfo()
.fail_on_error()
.emit()?;
Ok(())
}
2 changes: 1 addition & 1 deletion data/icons.gresource.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/miguelbaldi/krust/icons/">
<gresource prefix="/io/miguelbaldi/KRust/icons/">
<file alias="krust-icon.ico">images/krust.ico</file>
</gresource>
</gresources>
27 changes: 27 additions & 0 deletions data/images/io.miguelbaldi.KRust-symbolic.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions data/images/io.miguelbaldi.KRust.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion data/resources.gresource.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/miguelbaldi/krust/">
<gresource prefix="/io/miguelbaldi/KRust/">
<file preprocess="xml-stripblanks" alias="icons/scalable/apps/io.miguelbaldi.KRust.svg">images/io.miguelbaldi.KRust.svg</file>
<file preprocess="xml-stripblanks" alias="icons/symbolic/apps/io.miguelbaldi.KRust-symbolic.svg">images/io.miguelbaldi.KRust-symbolic.svg</file>

<file alias="logo.png">images/logo.png</file>
<file preprocess="xml-stripblanks" alias="logo.svg">images/logo.svg</file>
<file preprocess="xml-stripblanks" alias="logo-no-background.svg">images/logo-no-background.svg</file>
Expand Down
8 changes: 4 additions & 4 deletions src/component/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{
topics_page::{TopicsPageModel, TopicsPageMsg, TopicsPageOutput},
},
config::State,
modals::about::AboutDialog,
modals::about::AboutDialog, APP_ID, APP_NAME, APP_RESOURCE_PATH,
};

use super::{
Expand Down Expand Up @@ -82,8 +82,8 @@ impl Component for AppModel {
view! {
main_window = adw::ApplicationWindow::new(&main_adw_application()) {
set_visible: true,
set_title: Some("KRust Kafka Client"),
set_icon_name: Some("krust-icon"),
set_title: Some(APP_NAME),
set_icon_name: Some(APP_ID),
gtk::Box {
set_orientation: gtk::Orientation::Vertical,

Expand Down Expand Up @@ -236,7 +236,7 @@ impl Component for AppModel {
info!("widgets loaded");
widgets
.support_logo
.set_resource(Some("/org/miguelbaldi/krust/logo.png"));
.set_resource(Some(format!("{}logo.png", APP_RESOURCE_PATH).as_str()));

let mut actions = RelmActionGroup::<WindowActionGroup>::new();

Expand Down
17 changes: 8 additions & 9 deletions src/component/messages/messages_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ impl FactoryComponent for MessagesTabModel {
gtk::SearchEntry {
set_hexpand: false,
set_halign: gtk::Align::Fill,
set_width_chars: 50,
connect_search_changed[sender] => move |entry| {
sender.clone().input(MessagesTabMsg::LiveSearchMessages(entry.text().to_string()));
},
Expand Down Expand Up @@ -593,6 +594,7 @@ impl FactoryComponent for MessagesTabModel {
};
self.page_size = page_size;
self.page_size_combo.widget().queue_allocate();
sender.input(MessagesTabMsg::SearchMessages);
}
MessagesTabMsg::FetchTypeChanged(_idx) => {
let fetch_type = match self.fetch_type_combo.model().get_active_elem() {
Expand Down Expand Up @@ -633,13 +635,6 @@ impl FactoryComponent for MessagesTabModel {
CommandMsg::CopyToClipboard(String::default())
}
});
// if let Ok(data) = data {
// DisplayManager::get()
// .default_display()
// .unwrap()
// .clipboard()
// .set_text(data.as_str());
// }
}
MessagesTabMsg::Open(connection, topic) => {
let conn_id = &connection.id.unwrap();
Expand Down Expand Up @@ -993,11 +988,15 @@ fn fill_pagination(
}
(_, _) => (),
}
debug!("fill pagination of current page {}", current_page);
debug!("fill pagination of current page {} of {}", current_page, pages);
match current_page {
1 => {
1 if pages == 1 => {
widgets.btn_next_page.set_sensitive(false);
widgets.btn_previous_page.set_sensitive(false);
}
1 => {
widgets.btn_next_page.set_sensitive(true);
widgets.btn_previous_page.set_sensitive(false);
}
n if n >= pages => {
widgets.btn_next_page.set_sensitive(false);
Expand Down

0 comments on commit ba067be

Please sign in to comment.