[fractal/bilelmoussaoui/bump-gtk-rs: 2/7] replace all the new_from with just from_
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/bilelmoussaoui/bump-gtk-rs: 2/7] replace all the new_from with just from_
- Date: Wed, 15 Jul 2020 17:36:11 +0000 (UTC)
commit f6a3c3932d391591ef8f678c45a1372e1aa0776c
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date: Wed Jul 15 18:39:41 2020 +0200
replace all the new_from with just from_
part of the new gtk-rs changes
fractal-gtk/src/actions/message.rs | 2 +-
fractal-gtk/src/appop/account.rs | 5 ++---
fractal-gtk/src/appop/attach.rs | 6 +++---
fractal-gtk/src/appop/message.rs | 2 +-
fractal-gtk/src/static_resources.rs.in | 2 +-
fractal-gtk/src/widgets/address.rs | 10 ++++------
fractal-gtk/src/widgets/avatar.rs | 6 +++---
fractal-gtk/src/widgets/image.rs | 4 ++--
fractal-gtk/src/widgets/inline_player.rs | 8 ++++----
fractal-gtk/src/widgets/login.rs | 2 +-
fractal-gtk/src/widgets/media_viewer.rs | 8 +++-----
fractal-gtk/src/widgets/message.rs | 16 +++++++---------
fractal-gtk/src/widgets/room.rs | 4 ++--
fractal-gtk/src/widgets/room_settings.rs | 2 +-
fractal-gtk/src/widgets/roomlist.rs | 2 +-
fractal-gtk/src/widgets/roomrow.rs | 2 +-
fractal-gtk/src/widgets/sourceview_entry.rs | 9 ++++-----
17 files changed, 41 insertions(+), 49 deletions(-)
---
diff --git a/fractal-gtk/src/actions/message.rs b/fractal-gtk/src/actions/message.rs
index 17f6ae66..9214f869 100644
--- a/fractal-gtk/src/actions/message.rs
+++ b/fractal-gtk/src/actions/message.rs
@@ -195,7 +195,7 @@ pub fn new(
Continue(true)
}
Ok(Ok(fname)) => {
- if let Ok(pixbuf) = gdk_pixbuf::Pixbuf::new_from_file(fname) {
+ if let Ok(pixbuf) = gdk_pixbuf::Pixbuf::from_file(fname) {
let atom = gdk::Atom::intern("CLIPBOARD");
let clipboard = gtk::Clipboard::get(&atom);
diff --git a/fractal-gtk/src/appop/account.rs b/fractal-gtk/src/appop/account.rs
index 31acb8f0..2b22a933 100644
--- a/fractal-gtk/src/appop/account.rs
+++ b/fractal-gtk/src/appop/account.rs
@@ -331,7 +331,7 @@ impl AppOp {
name_btn.hide();
name.set_editable(true);
- let image = gtk::Image::new_from_icon_name(Some("emblem-ok-symbolic"), gtk::IconSize::Menu);
+ let image = gtk::Image::from_icon_name(Some("emblem-ok-symbolic"), gtk::IconSize::Menu);
name_btn.set_image(Some(&image));
name_btn.set_sensitive(true);
@@ -568,8 +568,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(Some("emblem-ok-symbolic"), gtk::IconSize::Menu);
+ let image = gtk::Image::from_icon_name(Some("emblem-ok-symbolic"), gtk::IconSize::Menu);
button.set_image(Some(&image));
button.set_sensitive(true);
entry.set_editable(true);
diff --git a/fractal-gtk/src/appop/attach.rs b/fractal-gtk/src/appop/attach.rs
index 3f0813aa..dddceabf 100644
--- a/fractal-gtk/src/appop/attach.rs
+++ b/fractal-gtk/src/appop/attach.rs
@@ -33,7 +33,7 @@ impl AppOp {
.get_object("main_window")
.expect("Can't find main_window in ui file.");
let img = gtk::Image::new();
- let dialog = gtk::Dialog::new_with_buttons(
+ let dialog = gtk::Dialog::with_buttons(
Some(i18n("Image from Clipboard").as_str()),
Some(&window),
gtk::DialogFlags::MODAL
@@ -49,8 +49,8 @@ impl AppOp {
if let Some(hbar) = dialog.get_header_bar() {
let headerbar = 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());
+ let closebtn = gtk::Button::with_label(i18n("Cancel").as_str());
+ let okbtn = gtk::Button::with_label(i18n("Send").as_str());
okbtn.get_style_context().add_class("suggested-action");
headerbar.set_show_close_button(false);
diff --git a/fractal-gtk/src/appop/message.rs b/fractal-gtk/src/appop/message.rs
index a1d1365e..be64def7 100644
--- a/fractal-gtk/src/appop/message.rs
+++ b/fractal-gtk/src/appop/message.rs
@@ -577,7 +577,7 @@ fn get_image_media_info(file: &str, mimetype: &str) -> Option<JsonValue> {
let size = fs::metadata(&file).ok()?.len();
// make thumbnail max 800x600
- let thumb = Pixbuf::new_from_file_at_scale(&file, 800, 600, true).ok()?;
+ let thumb = Pixbuf::from_file_at_scale(&file, 800, 600, true).ok()?;
let mut rng = rand::thread_rng();
let x: u64 = rng.gen_range(1, 9_223_372_036_854_775_807);
let thumb_path = format!(
diff --git a/fractal-gtk/src/static_resources.rs.in b/fractal-gtk/src/static_resources.rs.in
index 28207a6f..a578fedb 100644
--- a/fractal-gtk/src/static_resources.rs.in
+++ b/fractal-gtk/src/static_resources.rs.in
@@ -11,7 +11,7 @@ pub fn init() -> Result<(), Error> {
// Create Resource, it will live as long the value lives.
let gbytes = Bytes::from(res_bytes.as_ref());
- let resource = Resource::new_from_data(&gbytes)?;
+ let resource = Resource::from_data(&gbytes)?;
// Register the resource so It wont be dropped and will continue to live in memory.
resources_register(&resource);
diff --git a/fractal-gtk/src/widgets/address.rs b/fractal-gtk/src/widgets/address.rs
index 883d229c..43c57c2d 100644
--- a/fractal-gtk/src/widgets/address.rs
+++ b/fractal-gtk/src/widgets/address.rs
@@ -61,7 +61,7 @@ impl<'a> Address<'a> {
self.action = Some(AddressAction::Delete);
let label =
- gtk::Image::new_from_icon_name(Some("user-trash-symbolic"), gtk::IconSize::Menu);
+ gtk::Image::from_icon_name(Some("user-trash-symbolic"), gtk::IconSize::Menu);
self.button.set_image(Some(&label));
self.button.show();
} else {
@@ -72,8 +72,7 @@ impl<'a> Address<'a> {
self.entry.set_placeholder_text(Some(text));
self.action = Some(AddressAction::Add);
- let label =
- gtk::Image::new_from_icon_name(Some("list-add-symbolic"), gtk::IconSize::Menu);
+ let label = gtk::Image::from_icon_name(Some("list-add-symbolic"), gtk::IconSize::Menu);
self.button.set_image(Some(&label));
self.button
.get_style_context()
@@ -102,7 +101,7 @@ impl<'a> Address<'a> {
self.action = Some(AddressAction::Delete);
let label =
- gtk::Image::new_from_icon_name(Some("user-trash-symbolic"), gtk::IconSize::Menu);
+ gtk::Image::from_icon_name(Some("user-trash-symbolic"), gtk::IconSize::Menu);
self.button.set_image(Some(&label));
self.button
.get_style_context()
@@ -110,8 +109,7 @@ impl<'a> Address<'a> {
self.button.show();
} else {
self.action = Some(AddressAction::Add);
- let label =
- gtk::Image::new_from_icon_name(Some("list-add-symbolic"), gtk::IconSize::Menu);
+ let label = gtk::Image::from_icon_name(Some("list-add-symbolic"), gtk::IconSize::Menu);
self.button.set_image(Some(&label));
self.button
.get_style_context()
diff --git a/fractal-gtk/src/widgets/avatar.rs b/fractal-gtk/src/widgets/avatar.rs
index fcd1fe34..dc5a7438 100644
--- a/fractal-gtk/src/widgets/avatar.rs
+++ b/fractal-gtk/src/widgets/avatar.rs
@@ -191,14 +191,14 @@ impl AvatarExt for gtk::Overlay {
}
fn load_pixbuf(path: &str, size: i32) -> Option<Pixbuf> {
- if let Ok(pixbuf) = Pixbuf::new_from_file(&path) {
+ if let Ok(pixbuf) = Pixbuf::from_file(&path) {
// FIXME: We end up loading the file twice but we need to load the file first to find out its
dimensions to be
// able to decide wether to scale by width or height and gdk doesn't provide simple API to scale a
loaded
// pixbuf while preserving aspect ratio.
if pixbuf.get_width() > pixbuf.get_height() {
- Pixbuf::new_from_file_at_scale(&path, -1, size, true).ok()
+ Pixbuf::from_file_at_scale(&path, -1, size, true).ok()
} else {
- Pixbuf::new_from_file_at_scale(&path, size, -1, true).ok()
+ Pixbuf::from_file_at_scale(&path, size, -1, true).ok()
}
} else {
None
diff --git a/fractal-gtk/src/widgets/image.rs b/fractal-gtk/src/widgets/image.rs
index ffaafe12..03c71971 100644
--- a/fractal-gtk/src/widgets/image.rs
+++ b/fractal-gtk/src/widgets/image.rs
@@ -311,7 +311,7 @@ pub fn load_pixbuf(
return;
}
- match Pixbuf::new_from_file(fname) {
+ match Pixbuf::from_file(fname) {
Ok(px) => {
*pix.lock().unwrap() = Some(px);
*scaled.lock().unwrap() = None;
@@ -340,7 +340,7 @@ pub fn load_animation(
widget: DrawingArea,
fname: &str,
) {
- let res = PixbufAnimation::new_from_file(fname);
+ let res = PixbufAnimation::from_file(fname);
if res.is_err() {
return;
}
diff --git a/fractal-gtk/src/widgets/inline_player.rs b/fractal-gtk/src/widgets/inline_player.rs
index 8b7502f8..b086edab 100644
--- a/fractal-gtk/src/widgets/inline_player.rs
+++ b/fractal-gtk/src/widgets/inline_player.rs
@@ -247,7 +247,7 @@ impl Default for VideoPlayerWidget {
let dispatcher = gst_player::PlayerGMainContextSignalDispatcher::new(None);
let sink = gst::ElementFactory::make("gtksink", None)
.expect("Missing dependency: element gtksink is needed (usually, in gstreamer-plugins-good or in
gst-plugin-gtk).");
- let renderer = gst_player::PlayerVideoOverlayVideoRenderer::new_with_sink(&sink).upcast();
+ let renderer = gst_player::PlayerVideoOverlayVideoRenderer::with_sink(&sink).upcast();
let player = gst_player::Player::new(
Some(&renderer),
// Use the gtk main thread
@@ -564,14 +564,14 @@ impl<T: MediaPlayer + 'static> PlayerExt for T {
let player = player_widget.get_player();
if player.get_mute() {
player.set_mute(false);
- let image = gtk::Image::new_from_icon_name(
+ let image = gtk::Image::from_icon_name(
Some("audio-volume-high-symbolic"),
gtk::IconSize::Button,
);
button.set_image(Some(&image));
} else {
player.set_mute(true);
- let image = gtk::Image::new_from_icon_name(
+ let image = gtk::Image::from_icon_name(
Some("audio-volume-muted-symbolic"),
gtk::IconSize::Button,
);
@@ -626,7 +626,7 @@ impl<T: MediaPlayer + 'static> ControlsConnection for T {
}
fn create_controls(player: &gst_player::Player) -> PlayerControls {
- let builder = gtk::Builder::new_from_resource("/org/gnome/Fractal/ui/audio_player.ui");
+ let builder = gtk::Builder::from_resource("/org/gnome/Fractal/ui/audio_player.ui");
let container = builder.get_object("container").unwrap();
let buttons_container = builder.get_object("buttons").unwrap();
diff --git a/fractal-gtk/src/widgets/login.rs b/fractal-gtk/src/widgets/login.rs
index 48784f22..f7d47bff 100644
--- a/fractal-gtk/src/widgets/login.rs
+++ b/fractal-gtk/src/widgets/login.rs
@@ -151,7 +151,7 @@ impl LoginWidget {
impl Default for LoginWidget {
fn default() -> Self {
- let builder = gtk::Builder::new_from_resource("/org/gnome/Fractal/ui/login_flow.ui");
+ let builder = gtk::Builder::from_resource("/org/gnome/Fractal/ui/login_flow.ui");
let container: gtk::Stack = builder.get_object("login_flow_stack").unwrap();
let headers: gtk::Stack = builder.get_object("login_flow_headers").unwrap();
diff --git a/fractal-gtk/src/widgets/media_viewer.rs b/fractal-gtk/src/widgets/media_viewer.rs
index f2c95773..3201e19f 100644
--- a/fractal-gtk/src/widgets/media_viewer.rs
+++ b/fractal-gtk/src/widgets/media_viewer.rs
@@ -378,15 +378,13 @@ impl Data {
let control_box = PlayerExt::get_controls_container(&player).unwrap();
full_control_box.pack_start(&control_box, false, true, 0);
- let mute_button = gtk::Button::new_from_icon_name(
- Some("audio-volume-high-symbolic"),
- gtk::IconSize::Button,
- );
+ let mute_button =
+ gtk::Button::from_icon_name(Some("audio-volume-high-symbolic"), gtk::IconSize::Button);
/* The followign callback requires `Send` but is handled by the gtk main loop */
let button = Fragile::new(mute_button.clone());
PlayerExt::get_player(&player).connect_state_changed(move |player, state| match state {
gst_player::PlayerState::Playing if player.get_mute() => {
- let image = gtk::Image::new_from_icon_name(
+ let image = gtk::Image::from_icon_name(
Some("audio-volume-muted-symbolic"),
gtk::IconSize::Button,
);
diff --git a/fractal-gtk/src/widgets/message.rs b/fractal-gtk/src/widgets/message.rs
index 562327f2..126edaae 100644
--- a/fractal-gtk/src/widgets/message.rs
+++ b/fractal-gtk/src/widgets/message.rs
@@ -247,10 +247,8 @@ impl MessageBox {
body_bx.pack_start(&body, true, true, 0);
if let Some(replace_date) = msg.replace_date {
- let edit_mark = gtk::Image::new_from_icon_name(
- Some("document-edit-symbolic"),
- gtk::IconSize::Button,
- );
+ let edit_mark =
+ gtk::Image::from_icon_name(Some("document-edit-symbolic"), gtk::IconSize::Button);
edit_mark.get_style_context().add_class("edit-mark");
edit_mark.set_valign(gtk::Align::End);
@@ -464,7 +462,7 @@ impl MessageBox {
);
let download_btn =
- gtk::Button::new_from_icon_name(Some("document-save-symbolic"), gtk::IconSize::Button);
+ gtk::Button::from_icon_name(Some("document-save-symbolic"), gtk::IconSize::Button);
download_btn.set_tooltip_text(Some(i18n("Save").as_str()));
let evid = msg
@@ -514,7 +512,7 @@ impl MessageBox {
overlay.add(&video_widget);
let play_button = gtk::Button::new();
- let play_icon = gtk::Image::new_from_icon_name(
+ let play_icon = gtk::Image::from_icon_name(
Some("media-playback-start-symbolic"),
gtk::IconSize::Dialog,
);
@@ -536,7 +534,7 @@ impl MessageBox {
let menu_button = gtk::MenuButton::new();
let three_dot_icon =
- gtk::Image::new_from_icon_name(Some("view-more-symbolic"), gtk::IconSize::Button);
+ gtk::Image::from_icon_name(Some("view-more-symbolic"), gtk::IconSize::Button);
menu_button.set_image(Some(&three_dot_icon));
menu_button.get_style_context().add_class("osd");
menu_button.get_style_context().add_class("round-button");
@@ -579,7 +577,7 @@ impl MessageBox {
name_lbl.get_style_context().add_class("msg-highlighted");
let download_btn =
- gtk::Button::new_from_icon_name(Some("document-save-symbolic"), gtk::IconSize::Button);
+ gtk::Button::from_icon_name(Some("document-save-symbolic"), gtk::IconSize::Button);
download_btn.set_tooltip_text(Some(i18n("Save").as_str()));
let evid = msg
@@ -593,7 +591,7 @@ impl MessageBox {
download_btn.set_action_name(Some("message.save_as"));
let open_btn =
- gtk::Button::new_from_icon_name(Some("document-open-symbolic"), gtk::IconSize::Button);
+ gtk::Button::from_icon_name(Some("document-open-symbolic"), gtk::IconSize::Button);
open_btn.set_tooltip_text(Some(i18n("Open").as_str()));
let data = glib::Variant::from(&evid);
diff --git a/fractal-gtk/src/widgets/room.rs b/fractal-gtk/src/widgets/room.rs
index 531ef6d6..389980f1 100644
--- a/fractal-gtk/src/widgets/room.rs
+++ b/fractal-gtk/src/widgets/room.rs
@@ -115,13 +115,13 @@ impl<'a> RoomBox<'a> {
membership_grid.set_column_spacing(6);
let members_icon =
- gtk::Image::new_from_icon_name(Some("system-users-symbolic"), gtk::IconSize::Menu);
+ gtk::Image::from_icon_name(Some("system-users-symbolic"), gtk::IconSize::Menu);
members_icon.get_style_context().add_class("dim-label");
let members_count = gtk::Label::new(Some(&format!("{}", room.n_members)[..]));
members_count.get_style_context().add_class("dim-label");
- let join_button = gtk::Button::new_with_label(i18n("Join").as_str());
+ let join_button = gtk::Button::with_label(i18n("Join").as_str());
let room_id = room.id.clone();
join_button.connect_clicked(move |_| {
let server_url = login_data.server_url.clone();
diff --git a/fractal-gtk/src/widgets/room_settings.rs b/fractal-gtk/src/widgets/room_settings.rs
index 45410482..3b0a0506 100644
--- a/fractal-gtk/src/widgets/room_settings.rs
+++ b/fractal-gtk/src/widgets/room_settings.rs
@@ -277,7 +277,7 @@ impl RoomSettings {
}
pub fn reset_action_button(&self, button: gtk::Button) {
- let image = gtk::Image::new_from_icon_name(Some("emblem-ok-symbolic"), gtk::IconSize::Menu);
+ let image = gtk::Image::from_icon_name(Some("emblem-ok-symbolic"), gtk::IconSize::Menu);
button.set_image(Some(&image));
button.set_sensitive(true);
}
diff --git a/fractal-gtk/src/widgets/roomlist.rs b/fractal-gtk/src/widgets/roomlist.rs
index 1a9fee5c..3e68f8b9 100644
--- a/fractal-gtk/src/widgets/roomlist.rs
+++ b/fractal-gtk/src/widgets/roomlist.rs
@@ -86,7 +86,7 @@ impl RoomListGroup {
title.set_halign(gtk::Align::Start);
title.set_valign(gtk::Align::Start);
let arrow =
- gtk::Image::new_from_icon_name(Some("pan-down-symbolic"), gtk::IconSize::SmallToolbar);
+ gtk::Image::from_icon_name(Some("pan-down-symbolic"), gtk::IconSize::SmallToolbar);
let expanded = Arc::new(AtomicBool::new(true));
let title_eb = gtk::EventBox::new();
diff --git a/fractal-gtk/src/widgets/roomrow.rs b/fractal-gtk/src/widgets/roomrow.rs
index 444de44d..fc520ddf 100644
--- a/fractal-gtk/src/widgets/roomrow.rs
+++ b/fractal-gtk/src/widgets/roomrow.rs
@@ -28,7 +28,7 @@ impl RoomRow {
let icon = widgets::Avatar::avatar_new(Some(ICON_SIZE));
let direct =
- gtk::Image::new_from_icon_name(Some("avatar-default-symbolic"), gtk::IconSize::Menu);
+ gtk::Image::from_icon_name(Some("avatar-default-symbolic"), gtk::IconSize::Menu);
direct.get_style_context().add_class("direct-chat");
let text = gtk::Label::new(Some(name.as_str()));
diff --git a/fractal-gtk/src/widgets/sourceview_entry.rs b/fractal-gtk/src/widgets/sourceview_entry.rs
index be8148a6..f7eb9526 100644
--- a/fractal-gtk/src/widgets/sourceview_entry.rs
+++ b/fractal-gtk/src/widgets/sourceview_entry.rs
@@ -34,7 +34,7 @@ impl Default for SVEntry {
let size = gtk::IconSize::Button;
let attach = gtk::Button::new();
- let attach_img = gtk::Image::new_from_icon_name(Some("mail-attachment-symbolic"), size);
+ let attach_img = gtk::Image::from_icon_name(Some("mail-attachment-symbolic"), size);
attach.set_image(Some(&attach_img));
attach.set_valign(gtk::Align::End);
attach.set_receives_default(true);
@@ -47,8 +47,7 @@ impl Default for SVEntry {
*/
let markdown = gtk::MenuButton::new();
- let markdown_img =
- gtk::Image::new_from_icon_name(Some("format-justify-left-symbolic"), size);
+ let markdown_img = gtk::Image::from_icon_name(Some("format-justify-left-symbolic"), size);
markdown.set_image(Some(&markdown_img));
markdown.set_valign(gtk::Align::End);
markdown.set_receives_default(true);
@@ -68,7 +67,7 @@ impl Default for SVEntry {
let tag_table: Option<>k::TextTagTable> = None;
let buffer = sourceview4::Buffer::new(tag_table);
- let view = sourceview4::View::new_with_buffer(&buffer);
+ let view = sourceview4::View::with_buffer(&buffer);
view.set_wrap_mode(gtk::WrapMode::WordChar);
view.set_indent_on_tab(false);
@@ -85,7 +84,7 @@ impl Default for SVEntry {
entry_box.add(&scroll);
let send = gtk::Button::new();
- let send_img = gtk::Image::new_from_icon_name(Some("send-symbolic"), size);
+ let send_img = gtk::Image::from_icon_name(Some("send-symbolic"), size);
send.set_image(Some(&send_img));
send.set_valign(gtk::Align::End);
send.set_receives_default(true);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]