Skip to content

Commit

Permalink
Keep contract submenu code together
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Wootten authored and Jeremy Wootten committed Dec 5, 2024
1 parent c41783b commit bfc6545
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 32 deletions.
24 changes: 12 additions & 12 deletions src/Views/CollectionPage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ public abstract class CollectionPage : MediaPage {
contractor_submenu.add (print_menu_item);
contractor_submenu.add (export_menu_item);

var source = get_view ().get_selected_at (0).source;
if (source != null && source is Photo) {
var file = ((Photo) source).get_file ();
if (file != null) {
var wallpaper_menuitem = new Gtk.MenuItem.with_label (_("Set as Wallpaper")) {
action_name = AppWindow.ACTION_PREFIX + AppWindow.ACTION_SET_WALLPAPER,
action_target = new Variant.string (file.get_uri ())
};
contractor_submenu.add (wallpaper_menuitem);
}
}

item_context_menu.add (copy_images_menu_item);
item_context_menu.add (adjust_datetime_menu_item);
item_context_menu.add (duplicate_menu_item);
Expand All @@ -234,18 +246,6 @@ public abstract class CollectionPage : MediaPage {
item_context_menu.add (remove_menu_item);
item_context_menu.add (trash_menu_item);
item_context_menu.show_all ();

var source = get_view ().get_selected_at (0).source;
if (source != null && source is Photo) {
var file = ((Photo) source).get_file ();
if (file != null) {
var wallpaper_menuitem = new Gtk.MenuItem.with_label (_("Set as Wallpaper")) {
action_name = AppWindow.ACTION_PREFIX + AppWindow.ACTION_SET_WALLPAPER,
action_target = new Variant.string (file.get_uri ())
};
contractor_submenu.add (wallpaper_menuitem);
}
}
}

populate_contractor_menu (contractor_submenu);
Expand Down
37 changes: 17 additions & 20 deletions src/Views/LibraryPhotoPage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class LibraryPhotoPage : EditingHostPage {
private CollectionPage? return_page = null;
private bool return_to_collection_on_release = false;
private LibraryPhotoPageViewFilter filter = new LibraryPhotoPageViewFilter ();
private Gtk.Menu contractor_menu;
private Gtk.Menu contractor_submenu;
private Gtk.Menu item_context_menu;

public LibraryPhotoPage () {
Expand Down Expand Up @@ -563,9 +563,21 @@ public class LibraryPhotoPage : EditingHostPage {
export_menu_item.activate.connect (() => export_action.activate ());

var contractor_menu_item = new Gtk.MenuItem.with_mnemonic (_("Other Actions"));
contractor_menu = new Gtk.Menu ();
contractor_menu_item.set_submenu (contractor_menu);

contractor_submenu = new Gtk.Menu ();
contractor_menu_item.set_submenu (contractor_submenu);
contractor_submenu.add (print_menu_item);
contractor_submenu.add (export_menu_item);
var source = get_view ().get_selected_at (0).source;
if (source != null && source is Photo) { // Cannot set other media as wallpaper
var file = ((Photo)source).get_file ();
if (file != null) {
var wallpaper_menuitem = new Gtk.MenuItem.with_label (_("Set as Wallpaper")) {
action_name = AppWindow.ACTION_PREFIX + AppWindow.ACTION_SET_WALLPAPER,
action_target = new Variant.string (file.get_uri ())
};
contractor_submenu.add (wallpaper_menuitem);
}
}
var remove_menu_item = new Gtk.MenuItem.with_mnemonic (Resources.REMOVE_FROM_LIBRARY_MENU);
var remove_action = get_action ("RemoveFromLibrary");
remove_action.bind_property ("sensitive", remove_menu_item, "sensitive", BindingFlags.SYNC_CREATE);
Expand All @@ -576,9 +588,6 @@ public class LibraryPhotoPage : EditingHostPage {
trash_action.bind_property ("sensitive", trash_menu_item, "sensitive", BindingFlags.SYNC_CREATE);
trash_menu_item.activate.connect (() => trash_action.activate ());

contractor_menu.add (print_menu_item);
contractor_menu.add (export_menu_item);

item_context_menu.add (adjust_datetime_menu_item);
item_context_menu.add (new Gtk.SeparatorMenuItem ());
item_context_menu.add (copy_image_menu_item);
Expand All @@ -601,21 +610,9 @@ public class LibraryPhotoPage : EditingHostPage {
item_context_menu.add (remove_menu_item);
item_context_menu.add (trash_menu_item);
item_context_menu.show_all ();

var source = get_view ().get_selected_at (0).source;
if (source != null && source is Photo) { // Cannot set other media as wallpaper
var file = ((Photo)source).get_file ();
if (file != null) {
var wallpaper_menuitem = new Gtk.MenuItem.with_label (_("Set as Wallpaper")) {
action_name = AppWindow.ACTION_PREFIX + AppWindow.ACTION_SET_WALLPAPER,
action_target = new Variant.string (file.get_uri ())
};
contractor_menu.add (wallpaper_menuitem);
}
}
}

populate_contractor_menu (contractor_menu);
populate_contractor_menu (contractor_submenu);
return item_context_menu;
}

Expand Down

0 comments on commit bfc6545

Please sign in to comment.