2020*/
2121
2222public class Spice.Widgets.ImageToolbar : Spice .Widgets .Toolbar {
23- private Gtk . MenuButton open_with;
23+ private Gtk . Button open_with;
2424 private Gtk . Button replace_image;
2525
2626 private unowned SlideManager manager;
@@ -30,12 +30,24 @@ public class Spice.Widgets.ImageToolbar : Spice.Widgets.Toolbar {
3030 }
3131
3232 construct {
33- open_with = new Gtk .MenuButton ();
33+ open_with = new Gtk .Button ();
3434 open_with. add (new Gtk .Image .from_icon_name (" applications-graphics-symbolic" , Gtk . IconSize . MENU ));
3535 open_with. set_tooltip_text (_(" Edit image with…" ));
3636 open_with. get_style_context (). add_class (Gtk . STYLE_CLASS_RAISED );
3737 open_with. get_style_context (). add_class (" image-button" );
3838
39+ open_with. clicked. connect (() = > {
40+ var image_item = (ImageItem ) item;
41+ var file = File . new_for_path (image_item. url);
42+
43+ try {
44+ Gtk . show_uri_on_window(Application . get_active_spice_window (), file. get_uri (), Gdk . CURRENT_TIME );
45+ } catch (Error e) {
46+ warning (" Could not launch open with portal %s " , e. message);
47+ return ;
48+ }
49+ });
50+
3951 replace_image = new Gtk .Button ();
4052 replace_image. add (new Gtk .Image .from_icon_name (" document-new-symbolic" , Gtk . IconSize . MENU ));
4153 replace_image. set_tooltip_text (_(" Replace Image…" ));
@@ -55,47 +67,7 @@ public class Spice.Widgets.ImageToolbar : Spice.Widgets.Toolbar {
5567 add (replace_image);
5668 }
5769
58- private void launch_editor (AppInfo app ) {
59- var list = new List<File > ();
60- list. append (File . new_for_path (((ImageItem ) this . item). url));
61-
62- try {
63- app. launch (list, null );
64- } catch (Error e) {
65- warning (" Could launch application: %s " , e. message);
66- }
67- }
68-
69- protected override void item_selected (Spice .CanvasItem ? _item , bool new_item = false ) {
70- var item = _item as Spice . ImageItem ;
71-
72- if (item != null ) {
73- var menu = new Gtk .Menu ();
74- open_with. popup = menu;
75-
76- var file = File . new_for_path (item. url);
77-
78- try {
79- var file_info = file. query_info (" standard::*" , 0 );
80-
81- var apps = AppInfo . get_all_for_type (file_info. get_content_type ());
82-
83- foreach (var app in apps) {
84- var meun_item = new Gtk .MenuItem .with_label (app. get_name ());
85- menu. add (meun_item);
86-
87- meun_item. activate. connect (() = > {
88- launch_editor (app);
89- });
90- }
91-
92- menu. show_all ();
93- } catch (Error e) {
94- warning (" Could not get file info %s " , e. message);
95- return ;
96- }
97- }
98- }
70+ protected override void item_selected (Spice .CanvasItem ? _item , bool new_item = false ) {}
9971
10072 public override void update_properties () {}
10173}
0 commit comments