🚧 fix toggle for groups

This commit is contained in:
Vladislav Nepogodin 2022-07-05 03:41:32 +04:00
parent 5be4a75d7b
commit e176a74b51
No known key found for this signature in database
GPG Key ID: B62C3D10C54D5DA9
5 changed files with 40 additions and 137 deletions

View File

@ -12,7 +12,7 @@
"style_path": "/usr/share/cachyos-hello/ui/style.css",
"urls": {
"development": "https://github.com/cachyos",
"discover": "https://github.com/cachyos/cachyos-pkgbuilds",
"software": "https://github.com/cachyos/cachyos-pkgbuilds",
"donate": "https://cachyos.org/donate",
"forum": "https://forum.cachyos.org",
"telegram": "https://t.me/+oR-kWT47vRdmMDli",

View File

@ -95,9 +95,9 @@ impl ApplicationBrowser {
String::static_type(),
String::static_type(),
String::static_type(),
bool::static_type(),
i32::static_type(),
String::static_type(),
bool::static_type(),
i32::static_type(),
];
Self {
@ -146,9 +146,9 @@ impl ApplicationBrowser {
(ICON, &g_icon),
(APPLICATION, &g_name),
(DESCRIPTION, &g_desc),
(ACTIVE, &false),
(ACTIVE, &-1),
(PACKAGE, &None::<String>),
(INSTALLED, &false),
(INSTALLED, &-1),
]);
store_size += 1;
@ -291,13 +291,11 @@ fn treeview_cell_app_data_function(
model: &gtk::TreeModel,
iter_a: &gtk::TreeIter,
) {
let value_gobj = model.value(iter_a, INSTALLED as i32);
let value = value_gobj.get::<bool>().unwrap();
if value {
renderer_cell.set_width(600);
} else {
renderer_cell.set_width(400);
}
let value_gobj = model.value(iter_a, INSTALLED as i32).get::<i32>();
match value_gobj {
Ok(1) | Ok(0) => renderer_cell.set_width(280),
_ => (),
};
}
fn treeview_cell_check_data_function(
@ -306,9 +304,9 @@ fn treeview_cell_check_data_function(
model: &gtk::TreeModel,
iter_a: &gtk::TreeIter,
) {
let value_gobj = model.value(iter_a, GROUP as i32);
let value = value_gobj.get::<&str>().is_ok();
renderer_cell.set_visible(!value);
// hide checkbox for groups
let value = model.value(iter_a, INSTALLED as i32).get::<i32>().unwrap();
renderer_cell.set_visible(value != -1);
}
fn on_reload_clicked(_button: &gtk::Button) {
@ -351,13 +349,11 @@ fn on_query_tooltip_tree_view(
let tooltip_context = treeview.tooltip_context(&mut x, &mut y, keyboard_tip);
if let Some((model_tmp, path, iter_a)) = tooltip_context {
let model = model_tmp.unwrap();
let value_gobj = model.value(&iter_a, INSTALLED as i32);
let value = value_gobj.get::<bool>();
if value.is_ok() && value.unwrap() {
let value = model.value(&iter_a, INSTALLED as i32).get::<i32>().unwrap();
if value == 1 {
let mut msg = String::from("Installed");
let active_gobj = model.value(&iter_a, ACTIVE as i32);
let active = active_gobj.get::<bool>();
if active.is_ok() && !active.unwrap() {
let active = model.value(&iter_a, ACTIVE as i32).get::<i32>().unwrap();
if active == 0 {
msg.push_str(" , to remove");
}
tooltip.set_markup(Some(msg.as_str()));
@ -376,7 +372,7 @@ fn on_app_toggle(_cell: &gtk::CellRendererToggle, path: gtk::TreePath) {
// a group has no package attached and we don't install groups
if value_gobj.get::<&str>().is_ok() {
let toggle_a = app_store.value(&iter_a, ACTIVE as i32).get::<bool>().unwrap();
let toggle_a = app_store.value(&iter_a, ACTIVE as i32).get::<i32>().unwrap() == 1;
app_store.set(&iter_a, &[(ACTIVE, &!toggle_a)]);
let alpm_handle = app_browser.get_alpm_handle();

View File

@ -179,12 +179,6 @@ fn build_ui(application: &gtk::Application) {
if Path::new(&logo_path).exists() {
let logo = Pixbuf::from_file(logo_path).unwrap();
main_window.set_icon(Some(&logo));
let image: gtk::Image = builder.object("distriblogo").unwrap();
image.set_from_pixbuf(Some(&logo));
let dialog: gtk::AboutDialog = builder.object("aboutdialog").unwrap();
dialog.set_logo(Some(&logo));
}
let social_box: gtk::Box = builder.object("social").unwrap();
@ -344,9 +338,8 @@ fn set_locale(use_locale: &str) {
// Real-time locale changing
let elts: HashMap<String, serde_json::Value> = serde_json::from_str(&serde_json::to_string(&json!({
"comments": ["aboutdialog"],
"label": ["autostartlabel", "development", "discover", "donate", "firstcategory", "forum", "install", "installlabel", "involved", "mailling", "readme", "release", "secondcategory", "thirdcategory", "welcomelabel", "welcometitle", "wiki"],
"tooltip_text": ["about", "development", "discover", "donate", "forum", "mailling", "wiki"],
"label": ["autostartlabel", "development", "software", "donate", "firstcategory", "forum", "install", "installlabel", "involved", "mailling", "readme", "release", "secondcategory", "thirdcategory", "welcomelabel", "welcometitle", "wiki"],
"tooltip_text": ["about", "development", "software", "donate", "forum", "mailling", "wiki"],
})).unwrap()).unwrap();
let mut default_texts = json!(null);
@ -364,7 +357,7 @@ fn set_locale(use_locale: &str) {
let item_buf = item.property::<String>(method.0.as_str());
default_texts[method.0][elt_value] = json!(item_buf);
}
if method.0 == "tooltip_text" || method.0 == "comments" {
if method.0 == "tooltip_text" {
item.set_property(
method.0,
&gettextrs::gettext(default_texts[method.0][elt_value].as_str().unwrap()),

View File

@ -221,9 +221,9 @@ We, the CachyOS Developers, hope that you will enjoy using CachyOS as much as we
</packing>
</child>
<child>
<object class="GtkButton" id="discover">
<property name="label" translatable="yes">Discover software</property>
<property name="name">discover</property>
<object class="GtkButton" id="software">
<property name="label" translatable="yes">Software</property>
<property name="name">software</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="receives-default">True</property>
@ -423,23 +423,6 @@ We, the CachyOS Developers, hope that you will enjoy using CachyOS as much as we
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkButton" id="appBrowser">
<property name="label" translatable="yes">Install Apps</property>
<property name="name">appBrowser</property>
<property name="can-focus">False</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Install Apps</property>
<property name="margin-left">15</property>
<property name="margin-right">15</property>
<signal name="clicked" handler="on_btn_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="tweaksBrowser">
<property name="label" translatable="yes">Apps/Tweaks</property>
@ -458,7 +441,21 @@ We, the CachyOS Developers, hope that you will enjoy using CachyOS as much as we
</packing>
</child>
<child>
<placeholder/>
<object class="GtkButton" id="appBrowser">
<property name="label" translatable="yes">Install Apps</property>
<property name="name">appBrowser</property>
<property name="can-focus">False</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Common application selection</property>
<property name="margin-left">15</property>
<property name="margin-right">15</property>
<signal name="clicked" handler="on_btn_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
@ -494,12 +491,6 @@ We, the CachyOS Developers, hope that you will enjoy using CachyOS as much as we
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<object class="GtkEventBox">
<property name="name">reddit</property>
@ -584,81 +575,4 @@ We, the CachyOS Developers, hope that you will enjoy using CachyOS as much as we
</object>
</child>
</object>
<object class="GtkAboutDialog" id="aboutdialog">
<property name="can-focus">False</property>
<property name="title" translatable="yes">About</property>
<property name="type-hint">dialog</property>
<property name="transient-for">window</property>
<property name="program-name">CachyOS Hello</property>
<property name="version">0.6.10</property>
<property name="comments" translatable="yes">Welcome screen for CachyOS</property>
<property name="website">https://github.com/cachyos/cachyos-welcome</property>
<property name="website-label">GitHub</property>
<property name="authors">Hugo Posnic
Johnathan Jenkins
Frede Hundewadt
Bernhard Landauer
Philip Müller
Papa Joker
Oguz Kagan EREN</property>
<property name="translator-credits">abdelhak gasmi
Al Manja
Albert Cutrona
Aleksandar Velimirović
Alex Beliy
Bernhard Landauer
cges30901
Daniel Napora
DeMus
Ersi Ni
Fabio Forni
Gabriel Blanca
Hugo Carvalho
Hugo Posnic
Ilya Ostapenko aka Jacobtey
Jeff Huang
kouros kouros
Lajos Pasztor
László Szalai
Leandro Cunha
Lovro Kudelić
Makaveli B
mgundogdu
Michael Kogan
Midir Hakou
Moo
pavelrz
secgin
Stefano Capitani
Stéphane
Πέτρος Σαμαράς
Андрей Раугас</property>
<property name="logo-icon-name"/>
<property name="license-type">gpl-3-0</property>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can-focus">True</property>
<property name="has-focus">True</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="layout-style">end</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<style>
<class name="aboutdialog"/>
</style>
</object>
</interface>