Commit 38628c43 authored by Christopher Davis's avatar Christopher Davis 🌱

Update gtk-rs stack

Closes #489
parent e9be611e
This diff is collapsed.
......@@ -11,40 +11,40 @@ comrak = "0.4.0"
dirs = "1.0.4"
failure = "0.1.3"
fragile = "0.3.0"
gspell = "0.1.0"
gdk = "0.9.0"
gdk-pixbuf = "0.5.0"
gdk-pixbuf-sys = "0.7.0"
gstreamer-editing-services = "0.12.2"
glib = "0.6.1"
gspell = "0.2.0"
gdk = "0.10.0"
gdk-pixbuf = "0.6.0"
gdk-pixbuf-sys = "0.8.0"
gstreamer-editing-services = "0.13.0"
glib = "0.7.1"
itertools = "0.8.0"
lazy_static = "1.2.0"
letter-avatar = "1.0.2"
log = "0.4.6"
loggerv = "0.7.1"
mdl = "1.0.4"
pango = "0.5.0"
pangocairo = "0.6.0"
pango = "0.6.0"
pangocairo = "0.7.0"
rand = "0.6.1"
regex = "1.1.0"
secret-service = "0.4.0"
serde_json = "1.0.33"
sourceview = "0.5.0"
sourceview = "0.6.0"
url = "1.7.2"
[dependencies.gst]
version = "0.12.2"
version = "0.13.0"
package = "gstreamer"
[dependencies.gst_player]
version = "0.12.2"
version = "0.13.0"
package = "gstreamer-player"
[dependencies.html2pango]
git = "https://gitlab.gnome.org/World/html2pango"
[dependencies.cairo-rs]
version = "0.5.0"
version = "0.6.0"
features = ["png"]
[dependencies.chrono]
......@@ -56,8 +56,8 @@ path = "../fractal-matrix-api"
package = "fractal-matrix-api"
[dependencies.libhandy]
version = "0.2.0"
features = ["v0_0_7"]
git = "https://gitlab.gnome.org/World/Rust/libhandy-rs"
features = ["v0_0_9"]
[dependencies.gettext-rs]
git = "https://github.com/danigm/gettext-rs"
......@@ -65,7 +65,7 @@ branch = "no-gettext"
features = ["gettext-system"]
[dependencies.gtk]
version = "0.5.0"
version = "0.6.0"
features = ["v3_22"]
[dependencies.serde]
......@@ -73,5 +73,5 @@ version = "1.0.82"
features = ["derive"]
[dependencies.gio]
version = "0.5.1"
version = "0.6.0"
features = ["v2_56"]
......@@ -28,7 +28,7 @@ pub fn new(window: &gtk::Window, backend: &Sender<BKCommand>) -> gio::SimpleActi
let window = upgrade_weak!(window_weak);
let filter = gtk::FileFilter::new();
filter.add_mime_type("image/*");
FileFilterExt::set_name(&filter, Some(i18n("Images").as_str()));
filter.set_name(Some(i18n("Images").as_str()));
if let Some(path) = open(&window, i18n("Select a new avatar").as_str(), &[filter]) {
if let Some(file) = path.to_str() {
a.change_state(&ButtonState::Insensitive.into());
......
use gio::SimpleAction;
use gio::SimpleActionExt;
use glib::Cast;
use glib::ObjectExt;
use glib::ToVariant;
......
......@@ -11,7 +11,6 @@ use crate::uibuilder::UI;
use crate::App;
use gio::ActionMapExt;
use gio::SimpleAction;
use gio::SimpleActionExt;
use gio::SimpleActionGroup;
use gtk;
use gtk::prelude::*;
......
......@@ -32,7 +32,7 @@ pub fn new(window: &gtk::Window, backend: &Sender<BKCommand>) -> gio::SimpleActi
if let Some(id) = data.as_ref().map(|x| x.to_string()) {
let window = upgrade_weak!(window_weak);
let filter = gtk::FileFilter::new();
FileFilterExt::set_name(&filter, Some(i18n("Images").as_str()));
filter.set_name(Some(i18n("Images").as_str()));
filter.add_mime_type("image/*");
if let Some(path) = open(&window, i18n("Select a new avatar").as_str(), &[filter]) {
if let Some(file) = path.to_str() {
......
......@@ -69,7 +69,8 @@ impl App {
let start = buffer.get_start_iter();
let end = buffer.get_end_iter();
let text = buffer.get_text(&start, &end, false);
let text = buffer.get_text(&start, &end, false)
.map_or(None, |gstr| Some(gstr.to_string()));
op.lock().unwrap().search_invite_user(text);
}
......@@ -83,9 +84,7 @@ impl App {
}));
to_chat_entry.connect_focus_in_event(clone!(op, to_chat_entry_box => move |_, _| {
if let Some(style) = to_chat_entry_box.get_style_context() {
style.add_class("message-input-focused");
}
to_chat_entry_box.get_style_context().add_class("message-input-focused");
op.lock().unwrap().remove_invite_user_dialog_placeholder();
......@@ -93,9 +92,7 @@ impl App {
}));
to_chat_entry.connect_focus_out_event(clone!(op, to_chat_entry_box => move |_, _| {
if let Some(style) = to_chat_entry_box.get_style_context() {
style.remove_class("message-input-focused");
}
to_chat_entry_box.get_style_context().remove_class("message-input-focused");
op.lock().unwrap().set_invite_user_dialog_placeholder();
......
......@@ -133,7 +133,7 @@ impl App {
other_homeserver_url_entry.set_sensitive(false);
}
let active = protocol_combo.get_active();
let active = protocol_combo.get_active().map_or(-1, |uint| uint as i32);
let protocol: String = match protocol_model.iter_nth_child(None, active) {
Some(it) => {
let v = protocol_model.get_value(&it, 0);
......@@ -147,7 +147,7 @@ impl App {
protocol_combo.connect_changed(
clone!(directory_choice_label, protocol_combo, protocol_model => move |_| {
let active = protocol_combo.get_active();
let active = protocol_combo.get_active().map_or(-1, |uint| uint as i32);
let protocol: String = match protocol_model.iter_nth_child(None, active) {
Some(it) => {
let v = protocol_model.get_value(&it, 0);
......
......@@ -105,7 +105,9 @@ impl App {
let text = buffer.get_text(&start, &end, false);
op.lock().unwrap().search_invite_user(text);
op.lock().unwrap().search_invite_user(
text.map_or(None, |gstr| Some(gstr.to_string()))
);
}
*(source_id.lock().unwrap()) = None;
......@@ -117,9 +119,7 @@ impl App {
}));
invite_entry.connect_focus_in_event(clone!(op, invite_entry_box => move |_, _| {
if let Some(style) = invite_entry_box.get_style_context() {
style.add_class("message-input-focused");
}
invite_entry_box.get_style_context().add_class("message-input-focused");
op.lock().unwrap().remove_invite_user_dialog_placeholder();
......@@ -127,9 +127,7 @@ impl App {
}));
invite_entry.connect_focus_out_event(clone!(op, invite_entry_box => move |_, _| {
if let Some(style) = invite_entry_box.get_style_context() {
style.remove_class("message-input-focused");
}
invite_entry_box.get_style_context().remove_class("message-input-focused");
op.lock().unwrap().set_invite_user_dialog_placeholder();
......
......@@ -41,8 +41,8 @@ impl App {
if md_active {
op.lock().unwrap().md_enabled = true;
markdown_switch.set_active(true);
md_img.set_from_icon_name("format-indent-more-symbolic", 1);
txt.get_style_context().unwrap().remove_class("dim-label");
md_img.set_from_icon_name("format-indent-more-symbolic", gtk::IconSize::Menu);
txt.get_style_context().remove_class("dim-label");
}
let op = op.clone();
......@@ -52,16 +52,17 @@ impl App {
op.lock().unwrap().md_enabled = markdown_switch.get_active();
if !markdown_switch.get_active() {
md_img.set_from_icon_name("format-justify-left-symbolic", 1);
txt.get_style_context().unwrap().add_class("dim-label");
md_img.set_from_icon_name("format-justify-left-symbolic", gtk::IconSize::Menu);
txt.get_style_context().add_class("dim-label");
util::set_markdown_schema(false);
let lang: Option<&sourceview::Language> = None;
buffer.set_highlight_matching_brackets(false);
buffer.set_language(None);
buffer.set_language(lang);
buffer.set_highlight_syntax(false);
} else {
md_img.set_from_icon_name("format-indent-more-symbolic", 1);
txt.get_style_context().unwrap().remove_class("dim-label");
md_img.set_from_icon_name("format-indent-more-symbolic", gtk::IconSize::Menu);
txt.get_style_context().remove_class("dim-label");
util::set_markdown_schema(true);
if let Some(md_lang) = md_lang.clone() {
......
......@@ -33,7 +33,10 @@ impl App {
}));
search_entry.connect_search_changed(clone!(op => move |entry| {
op.lock().unwrap().filter_rooms(entry.get_text());
op.lock().unwrap().filter_rooms(
entry.get_text()
.map_or(None, |gstr| Some(gstr.to_string()))
);
}));
// hidding left and right boxes to align with top buttons
......
......@@ -44,7 +44,7 @@ impl App {
let end = buffer.get_end_iter();
if let Some(text) = buffer.get_text(&start, &end, false) {
op.lock().unwrap().send_message(text);
op.lock().unwrap().send_message(text.to_string());
}
buffer.set_text("");
......@@ -61,17 +61,13 @@ impl App {
});
msg_entry.connect_focus_in_event(clone!(msg_entry_box => move |_, _| {
if let Some(style) = msg_entry_box.get_style_context() {
style.add_class("message-input-focused");
}
msg_entry_box.get_style_context().add_class("message-input-focused");
Inhibit(false)
}));
msg_entry.connect_focus_out_event(clone!(msg_entry_box => move |_, _| {
if let Some(style) = msg_entry_box.get_style_context() {
style.remove_class("message-input-focused");
}
msg_entry_box.get_style_context().remove_class("message-input-focused");
Inhibit(false)
}));
......
......@@ -124,7 +124,7 @@ impl App {
.get_application_id()
.map_or(false, |s| s.ends_with("Devel"))
{
window.get_style_context().map(|c| c.add_class("devel"));
window.get_style_context().add_class("devel");
}
let leaflet = ui
......@@ -137,10 +137,7 @@ impl App {
.expect("Can't find history_container in ui file.");
if let libhandy::Fold::Folded = leaflet.get_fold() {
container
.get_style_context()
.unwrap()
.add_class("folded-history");
container.get_style_context().add_class("folded-history");
}
let weak_container = container.downgrade();
......@@ -148,14 +145,10 @@ impl App {
let container = upgrade_weak!(weak_container);
match leaflet.get_fold() {
libhandy::Fold::Folded => container
.get_style_context()
.unwrap()
.add_class("folded-history"),
libhandy::Fold::Unfolded => container
.get_style_context()
.unwrap()
.remove_class("folded-history"),
libhandy::Fold::Folded => container.get_style_context().add_class("folded-history"),
libhandy::Fold::Unfolded => {
container.get_style_context().remove_class("folded-history");
}
_ => (),
}
});
......
......@@ -96,7 +96,7 @@ impl AppOp {
id_server.clone(),
secret.clone(),
sid.clone(),
token,
token.to_string(),
));
}
}
......@@ -284,7 +284,7 @@ impl AppOp {
name_btn.hide();
name.set_editable(true);
let image = gtk::Image::new_from_icon_name("emblem-ok-symbolic", 1);
let image = gtk::Image::new_from_icon_name("emblem-ok-symbolic", gtk::IconSize::Menu);
name_btn.set_image(&image);
name_btn.set_sensitive(true);
......@@ -480,7 +480,7 @@ impl AppOp {
.expect("Can't find account_settings_name_button in ui file.");
if let Some(name) = name.clone() {
button.hide();
let image = gtk::Image::new_from_icon_name("emblem-ok-symbolic", 1);
let image = gtk::Image::new_from_icon_name("emblem-ok-symbolic", gtk::IconSize::Menu);
button.set_image(&image);
button.set_sensitive(true);
entry.set_editable(true);
......@@ -502,7 +502,9 @@ impl AppOp {
.expect("Can't find account_settings_name_button in ui file.");
let old_username = self.username.clone().unwrap_or_default();
let username = name.get_text().unwrap_or_default();
let username = name
.get_text()
.map_or(String::new(), |gstr| gstr.to_string());
if old_username != username {
let spinner = gtk::Spinner::new();
......@@ -566,7 +568,11 @@ impl AppOp {
if old != "" && new != "" {
password_btn.set_sensitive(false);
password_btn_stack.set_visible_child_name("spinner");
let _ = self.backend.send(BKCommand::ChangePassword(mxid, old, new));
let _ = self.backend.send(BKCommand::ChangePassword(
mxid,
old.to_string(),
new.to_string(),
));
}
}
}
......@@ -666,6 +672,7 @@ impl AppOp {
if let Some(password) = entry.get_text() {
if let Some(mxid) = self.uid.clone() {
let backend = self.backend.clone();
let password = password.to_string();
dialog.connect_response(clone!(mxid, password, flag => move |w, r| {
match gtk::ResponseType::from(r) {
gtk::ResponseType::Ok => {
......
......@@ -19,7 +19,6 @@ use crate::App;
use crate::util::get_pixbuf_data;
use gdk_pixbuf;
use gdk_pixbuf::Pixbuf;
use gdk_pixbuf::PixbufExt;
impl AppOp {
fn draw_image_paste_dialog(&self, pixb: &Pixbuf) {
......@@ -57,10 +56,7 @@ impl AppOp {
let bar = hbar.downcast::<gtk::HeaderBar>().unwrap();
let closebtn = gtk::Button::new_with_label(i18n("Cancel").as_str());
let okbtn = gtk::Button::new_with_label(i18n("Send").as_str());
okbtn
.get_style_context()
.unwrap()
.add_class("suggested-action");
okbtn.get_style_context().add_class("suggested-action");
bar.set_show_close_button(false);
bar.pack_start(&closebtn);
......
......@@ -48,7 +48,7 @@ impl AppOp {
.get_object::<gtk::ListStore>("protocol_model")
.expect("Can't find protocol_model in ui file.");
let active = protocol_combo.get_active();
let active = protocol_combo.get_active().map_or(-1, |uint| uint as i32);
match protocol_model.iter_nth_child(None, active) {
Some(it) => {
let v = protocol_model.get_value(&it, 1);
......@@ -117,7 +117,7 @@ impl AppOp {
self.backend
.send(BKCommand::DirectorySearch(
homeserver,
q.get_text().unwrap(),
q.get_text().unwrap().to_string(),
protocol,
more,
))
......@@ -143,9 +143,7 @@ impl AppOp {
.builder
.get_object::<gtk::ListBox>("directory_room_list")
.expect("Can't find directory_room_list in ui file.");
directory
.get_style_context()
.map(|c| c.add_class("room-directory"));
directory.get_style_context().add_class("room-directory");
let directory_stack = self
.ui
......
......@@ -249,9 +249,9 @@ impl AppOp {
);
}
dialog.set_property_text(Some(&title));
dialog.set_property_text(Some(title.as_str()));
dialog.set_property_secondary_use_markup(true);
dialog.set_property_secondary_text(Some(&secondary));
dialog.set_property_secondary_text(Some(secondary.as_str()));
dialog.present();
}
......
......@@ -100,15 +100,15 @@ impl AppOp {
.expect("Can't find login_idp in ui file.");
let username = match user_entry.get_text() {
Some(s) => s,
Some(s) => s.to_string(),
None => String::new(),
};
let password = match pass_entry.get_text() {
Some(s) => s,
Some(s) => s.to_string(),
None => String::new(),
};
let passconf = match pass_conf.get_text() {
Some(s) => s,
Some(s) => s.to_string(),
None => String::new(),
};
......@@ -119,7 +119,7 @@ impl AppOp {
}
self.server_url = match server_entry.get_text() {
Some(s) => s,
Some(s) => s.to_string(),
None => String::from(globals::DEFAULT_HOMESERVER),
};
/* FIXME ask also for the identity server */
......
......@@ -106,7 +106,9 @@ impl AppOp {
users,
listbox,
scroll,
buffer.get_text(&start, &end, false),
buffer
.get_text(&start, &end, false)
.map_or(None, |gstr| Some(gstr.to_string())),
);
}
}
......@@ -135,7 +137,9 @@ impl AppOp {
users,
listbox,
scroll,
buffer.get_text(&start, &end, false),
buffer
.get_text(&start, &end, false)
.map_or(None, |gstr| Some(gstr.to_string())),
);
}
}
......
use comrak::{markdown_to_html, ComrakOptions};
use gdk_pixbuf::Pixbuf;
use gdk_pixbuf::PixbufExt;
use gio::prelude::{FileExt, FileInfoExt};
use gstreamer_editing_services::prelude::*;
use gstreamer_editing_services::UriClipAsset;
......@@ -241,7 +240,7 @@ impl AppOp {
if let Ok(info) = gio::File::new_for_path(&path).query_info(
&gio::FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
gio::FileQueryInfoFlags::NONE,
None,
gio::NONE_CANCELLABLE,
) {
// This should always return a type
let mime = info
......
use gio::ApplicationExt;
use gio::FileExt;
use gio::Notification;
use gio::NotificationExt;
use gtk;
use gtk::prelude::*;
use log::info;
......@@ -90,9 +89,8 @@ fn create_notification(room_id: &str, title: &str, body: &str, avatar: &str) ->
notification.set_body(body);
notification.set_priority(gio::NotificationPriority::High);
info!("Creating notification with avatar: {}", avatar);
let cancellable: Option<&gio::Cancellable> = None;
let file = gio::File::new_for_path(avatar);
let _ = file.load_bytes(cancellable).map(|(b, _)| {
let _ = file.load_bytes(gio::NONE_CANCELLABLE).map(|(b, _)| {
let avatar = gio::BytesIcon::new(&b);
notification.set_icon(&avatar);
});
......
......@@ -153,7 +153,7 @@ impl AppOp {
let msg_position = iter.get_offset();
self.unsent_messages
.insert(active_room.clone(), (msg, msg_position));
.insert(active_room.clone(), (msg.to_string(), msg_position));
}
} else {
self.unsent_messages.remove(active_room);
......@@ -237,7 +237,7 @@ impl AppOp {
"Leave {room_name}?",
&[("room_name", &r.name.clone().unwrap_or_default())],
);
dialog.set_property_text(Some(&text));
dialog.set_property_text(Some(text.as_str()));
dialog.present();
}
}
......@@ -267,8 +267,9 @@ impl AppOp {
.get_object::<gtk::ToggleButton>("private_visibility_button")
.expect("Can't find private_visibility_button in ui file.");
let n = name.get_text().unwrap_or_default();
let n = name
.get_text()
.map_or(String::new(), |gstr| gstr.to_string());
// Since the switcher
let p = if private.get_active() {
backend::RoomType::Private
......@@ -407,7 +408,11 @@ impl AppOp {
.get_object::<gtk::Entry>("join_room_name")
.expect("Can't find join_room_name in ui file.");
let n = name.get_text().unwrap_or_default().trim().to_string();
let n = name
.get_text()
.map_or(String::new(), |gstr| gstr.to_string())
.trim()
.to_string();
self.backend.send(BKCommand::JoinRoom(n.clone())).unwrap();
}
......@@ -577,7 +582,7 @@ impl AppOp {
typing_users.len() as u32,
typing_users
.iter()
.map(|user| markup_escape_text(&user.get_alias()))
.map(|user| markup_escape_text(&user.get_alias()).to_string())
.collect::<Vec<String>>()
.iter()
.map(std::ops::Deref::deref)
......
......@@ -58,7 +58,7 @@ fn main() -> Result<(), Box<dyn Error>> {
// Create a Application with default flags
let application = gtk::Application::new(config::APP_ID, gio::ApplicationFlags::empty())?;
application.set_property_resource_base_path(Some("/org/gnome/Fractal"));
application.set_resource_base_path(Some("/org/gnome/Fractal"));
application.connect_startup(|application| {
App::on_startup(application);
......
......@@ -3,7 +3,6 @@ use failure::format_err;
use failure::Error;
use gdk::ContextExt;
use gdk_pixbuf::Pixbuf;
use gdk_pixbuf::PixbufExt;
use gio::{Settings, SettingsExt, SettingsSchemaSource};
use html2pango::{html_escape, markup_links};
......
......@@ -57,7 +57,7 @@ impl<'a> Address<'a> {
self.entry.set_editable(false);
self.action = Some(AddressAction::Delete);
let label = gtk::Image::new_from_icon_name("user-trash-symbolic", 1);
let label = gtk::Image::new_from_icon_name("user-trash-symbolic", gtk::IconSize::Menu);
self.button.set_image(&label);
self.button.show();
} else {
......@@ -68,17 +68,15 @@ impl<'a> Address<'a> {
self.entry.set_placeholder_text(text);
self.action = Some(AddressAction::Add);
let label = gtk::Image::new_from_icon_name("list-add-symbolic", 1);
let label = gtk::Image::new_from_icon_name("list-add-symbolic", gtk::IconSize::Menu);
self.button.set_image(&label);
if let Some(style) = self.button.get_style_context() {
style.add_class("suggested-action");
}
self.button
.get_style_context()
.add_class("suggested-action");
self.button.hide();
self.entry.set_editable(true);
}
if let Some(style) = b.get_style_context() {
style.add_class("linked");
}
b.get_style_context().add_class("linked");
self.entry.show();
self.connect();
b.show();
......@@ -98,19 +96,19 @@ impl<'a> Address<'a> {
self.entry.set_editable(false);
self.action = Some(AddressAction::Delete);
let label = gtk::Image::new_from_icon_name("user-trash-symbolic", 1);
let label = gtk::Image::new_from_icon_name("user-trash-symbolic", gtk::IconSize::Menu);
self.button.set_image(&label);
if let Some(style) = self.button.get_style_context() {
style.remove_class("suggested-action");
}
self.button
.get_style_context()
.remove_class("suggested-action");
self.button.show();
} else {
self.action = Some(AddressAction::Add);
let label = gtk::Image::new_from_icon_name("list-add-symbolic", 1);
let label = gtk::Image::new_from_icon_name("list-add-symbolic", gtk::IconSize::Menu);
self.button.set_image(&label);
if let Some(style) = self.button.get_style_context() {
style.add_class("suggested-action");
}
self.button
.get_style_context()
.add_class("suggested-action");
self.button.hide();
self.entry.set_editable(true);
}
......@@ -180,7 +178,12 @@ impl<'a> Address<'a> {
delete_address(&backend, medium, address.clone());
}
Some(AddressAction::Add) => {
add_address(&backend, medium, id_server.clone(), entry.get_text());
add_address(
&backend,
medium,
id_server.clone(),
entry.get_text().map_or(None, |gstr| Some(gstr.to_string())),
);
}
_ => {}
}
......
......@@ -53,24 +53,21 @@ impl Autocomplete {
pub fn connect(self) {
let this: Rc<RefCell<Autocomplete>> = Rc::new(RefCell::new(self));
if let Some(context) =
gtk::Widget::get_style_context(&this.borrow().entry.clone().upcast::<gtk::Widget>())
{
if let Some(fg) = gtk::StyleContext::lookup_color(&context, "theme_selected_bg_color") {
let color = gdk::RGBA {
red: fg.red,
green: fg.green,
blue: fg.blue,
alpha: 1.0,
};
let tag = TextTag::new("alias-highlight");
tag.set_property_foreground_rgba(Some(&color));
if let Some(buffer) = this.borrow().entry.get_buffer() {
if let Some(tag_table) = buffer.get_tag_table() {
tag_table.add(&tag);
}
let context = this.borrow().entry.get_style_context();
if let Some(fg) = context.lookup_color("theme_selected_bg_color") {
let color = gdk::RGBA {
red: fg.red,
green: fg.green,
blue: fg.blue,
alpha: 1.0,
};
let tag = TextTag::new("alias-highlight");
tag.set_property_foreground_rgba(Some(&color));
if let Some(buffer) = this.borrow().entry.get_buffer() {
if let Some(tag_table) = buffer.get_tag_table() {
tag_table.add(&tag);
}
}
<