[fractal/bilelmoussaoui/bump-gtk-rs: 33/36] divider: replace the unsafe destroy




commit 0aac9f41a5d6d1400b871bd54ba2f0a98447e63d
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date:   Fri Jul 31 15:29:52 2020 +0200

    divider: replace the unsafe destroy

 Cargo.lock                         | 30 ++++++++++++++-----
 fractal-gtk/src/widgets/divider.rs |  4 ++-
 fractal-gtk/src/widgets/message.rs | 61 ++------------------------------------
 3 files changed, 27 insertions(+), 68 deletions(-)
---
diff --git a/Cargo.lock b/Cargo.lock
index daccb8a8..0303b631 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -919,10 +919,12 @@ dependencies = [
 
 [[package]]
 name = "gspell"
-version = "0.4.0"
-source = 
"git+https://gitlab.gnome.org/World/Rust/gspell-rs.git?rev=e4caf899ae387fa431bfa112cb3e40358b4b68ea#e4caf899ae387fa431bfa112cb3e40358b4b68ea";
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "8847f9b14fef52f6b02fee00009c3ca79b9d49f15f5dd724e8b9a81f07f15606"
 dependencies = [
  "gdk",
+ "gdk-pixbuf",
  "gdk-sys",
  "gio",
  "gio-sys",
@@ -937,9 +939,12 @@ dependencies = [
 
 [[package]]
 name = "gspell-sys"
-version = "0.4.0"
-source = 
"git+https://gitlab.gnome.org/World/Rust/gspell-rs.git?rev=e4caf899ae387fa431bfa112cb3e40358b4b68ea#e4caf899ae387fa431bfa112cb3e40358b4b68ea";
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "1ea17e07972015f24b381ec3a951601f7b3784b430aa60618bdb9b94038fe4b2"
 dependencies = [
+ "gdk-pixbuf-sys",
+ "gdk-sys",
  "glib-sys",
  "gobject-sys",
  "gtk-sys",
@@ -1418,8 +1423,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
 
 [[package]]
 name = "letter-avatar"
-version = "1.2.1"
-source = 
"git+https://gitlab.gnome.org/bilelmoussaoui/letter-avatar.git?branch=bump-gtk-rs#6df533cefc1f543c9bff2dee818030bf94730e19";
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "662660bd131a9c06b36730750de8049efb5d2c8e0c23b3b58e9dd87e61acc245"
 dependencies = [
  "cairo-rs",
  "pango",
@@ -1801,6 +1807,12 @@ dependencies = [
  "libc",
 ]
 
+[[package]]
+name = "object"
+version = "0.20.0"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5"
+
 [[package]]
 name = "once_cell"
 version = "1.4.1"
@@ -2573,7 +2585,8 @@ dependencies = [
 [[package]]
 name = "sourceview4"
 version = "0.2.0"
-source = 
"git+https://gitlab.gnome.org/World/Rust/sourceview4-rs.git?rev=275d8beb8a41b2a10321b0fd890a31de4700ed59#275d8beb8a41b2a10321b0fd890a31de4700ed59";
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "67cf21c78ea4fd60f3c321209952304d54d9ee8d543eaa321ec9d687525d65b0"
 dependencies = [
  "bitflags",
  "cairo-rs",
@@ -2595,7 +2608,8 @@ dependencies = [
 [[package]]
 name = "sourceview4-sys"
 version = "0.2.0"
-source = 
"git+https://gitlab.gnome.org/World/Rust/sourceview4-rs.git?rev=275d8beb8a41b2a10321b0fd890a31de4700ed59#275d8beb8a41b2a10321b0fd890a31de4700ed59";
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "1b24736d28cedce710e726ad2e511662e65f496ca54615724686fd14ad3bd490"
 dependencies = [
  "cairo-sys-rs",
  "gdk-pixbuf-sys",
diff --git a/fractal-gtk/src/widgets/divider.rs b/fractal-gtk/src/widgets/divider.rs
index 17efdbbd..708341a7 100644
--- a/fractal-gtk/src/widgets/divider.rs
+++ b/fractal-gtk/src/widgets/divider.rs
@@ -56,7 +56,9 @@ impl NewMessageDivider {
         revealer.connect_property_child_revealed_notify(clone!(
         @weak row as r
         => move |_| {
-            unsafe { r.destroy(); }
+            if let Some(container) = r.get_parent().and_then(|widget| 
widget.downcast::<gtk::ListBox>().ok()) {
+                container.remove(&r);
+            }
             remove_divider();
         }));
         NewMessageDivider {
diff --git a/fractal-gtk/src/widgets/message.rs b/fractal-gtk/src/widgets/message.rs
index 1b72bf43..c50bce51 100644
--- a/fractal-gtk/src/widgets/message.rs
+++ b/fractal-gtk/src/widgets/message.rs
@@ -512,15 +512,8 @@ impl MessageBox {
                 start_playing,
             );
 
-<<<<<<< HEAD
-            let overlay = Overlay::new();
-            let video_widget = player.get_video_widget();
-            video_widget.set_size_request(-1, 390);
-            VideoPlayerWidget::auto_adjust_video_dimensions(&player);
-            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,
             );
@@ -542,7 +535,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");
@@ -562,57 +555,7 @@ impl MessageBox {
             let redactable = msg.redactable;
             let menu = MessageMenu::new(evid, &RowType::Video, &redactable, None, None);
             menu_button.set_popover(Some(&menu.get_popover()));
-
-            bx.pack_start(&overlay, true, true, 0);
-            self.connect_media_viewer(msg);
-            self.video_player = Some(player);
         }
-=======
-        let play_button = gtk::Button::new();
-        let play_icon = gtk::Image::from_icon_name(
-            Some("media-playback-start-symbolic"),
-            gtk::IconSize::Dialog,
-        );
-        play_button.set_image(Some(&play_icon));
-        play_button.set_halign(gtk::Align::Center);
-        play_button.set_valign(gtk::Align::Center);
-        play_button.get_style_context().add_class("osd");
-        play_button.get_style_context().add_class("play-icon");
-        play_button.get_style_context().add_class("flat");
-        let evid = msg
-            .id
-            .as_ref()
-            .map(|evid| evid.to_string())
-            .unwrap_or_default();
-        let data = glib::Variant::from(evid);
-        play_button.set_action_name(Some("app.open-media-viewer"));
-        play_button.set_action_target_value(Some(&data));
-        overlay.add_overlay(&play_button);
-
-        let menu_button = gtk::MenuButton::new();
-        let three_dot_icon =
-            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");
-        menu_button.get_style_context().add_class("flat");
-        menu_button.set_margin_top(12);
-        menu_button.set_margin_end(12);
-        menu_button.set_opacity(0.8);
-        menu_button.set_halign(gtk::Align::End);
-        menu_button.set_valign(gtk::Align::Start);
-        menu_button.connect_size_allocate(|button, allocation| {
-            let diameter = max(allocation.width, allocation.height);
-            button.set_size_request(diameter, diameter);
-        });
-        overlay.add_overlay(&menu_button);
-
-        let evid = msg.id.as_ref();
-        let redactable = msg.redactable;
-        let menu = MessageMenu::new(evid, &RowType::Video, &redactable, None, None);
-        menu_button.set_popover(Some(&menu.get_popover()));
->>>>>>> f6a3c39... replace all the new_from with just from_
-
         bx
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]